我有一个简单的线性布局,并希望将屏幕分成两个大小相等的部分。适合父级布局的大小
在上面的那个,我想要放一个SurfaceView
,它的大小和它的父母一样大,即屏幕的一半。不幸的是,它总是需要全部屏幕或没有(取决于配置)。 这是为什么,我该如何改变它?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="vertical">
<LinearLayout android:id="@+id/layoutUpperDaw"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#192832">
<com.example.MySurvfaceView
android:id="@+id/id_mySurfaceView"
android:layout_width="match_parent"
android:layout_height="0pt"
android:layout_weight="1"
OR
android:layout_height="match_parent"
>
</com.example.MySurvfaceView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#193222">
...
</LinearLayout>
</LinearLayout>
不适用于我。那么'MySurfaceView'不可见。 – user1225905
@ user1225905查看已更新的答案 – Sharj
好的,没有第一个嵌套内部'LinearLayout'的方法可行,但我不确定是否有LinearLayout背后的逻辑。当我在'MySurvfaceView'周围添加'weight = 1'和'height = 0'的'LinearLayout'时,它不起作用。 – user1225905