我的本意是在线性布局下放三个控件:两个SurfaceView和一个Button,我的每个控件都设置了android:layout_weight这一属性,按照比例应该是4:4:1显示的,可是最终显示的时候,Button却没显示出来。其实我发现的SurfaceView类似的现象还有很多,先搞清楚这一个。请问这是什么原因?显示效果如下图:
这里是我的布局文件main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <SurfaceView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="@drawable/boud" android:id="@+id/sf13"
android:layout_weight="4">
<!-- drawable/boud"是我自定义的背景文件,作用是显示SurfaceView的边界 -->
</SurfaceView>
<SurfaceView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="@drawable/boud" android:id="@+id/sf15"
android:layout_weight="4">
</SurfaceView>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/bt22"
android:layout_weight="1"/>
</LinearLayout>
这里是我的布局文件main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <SurfaceView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="@drawable/boud" android:id="@+id/sf13"
android:layout_weight="4">
<!-- drawable/boud"是我自定义的背景文件,作用是显示SurfaceView的边界 -->
</SurfaceView>
<SurfaceView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="@drawable/boud" android:id="@+id/sf15"
android:layout_weight="4">
</SurfaceView>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/bt22"
android:layout_weight="1"/>
</LinearLayout>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货