我在一个相对的布局中有一个框架布局,其他的东西都在它下面。如何使这个帧布局占据整个屏幕的一半?
我试过体重,但这改变不了什么。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/mainLayoutStyle">
<FrameLayout
android:id="@+id/codeLayout"
style="@style/codeLayoutLargeStyle">
<TextView
android:id="@+id/DisplayTextView"
style="@style/DisplayTextViewLargeStyle"/>
</FrameLayout>
......
.....
<LinearLayout 发布于 2015-08-02 13:39:32
Marcin是对的,只有当您将父布局作为线性布局,而要使框架布局覆盖半屏幕时,权重属性才会有效,您必须将两个布局作为该线性布局的子布局,并将其除以相等的权重。
e.g
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/you_frame_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#00ff00">
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
希望这对你有帮助。
https://stackoverflow.com/questions/31772274
复制相似问题