我有一个 Fragment
,我需要从屏幕的底部到顶部,从屏幕的左边缘到80%。
我尝试使用android:layout_weight="0.8"
,即使我将<fragment>
嵌套在另一个<RelativeLayout>
或<LinearLayout>
现在,由于android:layout_height="fill_parent"
,高度从上到下跨越但是宽度仍然设置为wrap_content
,因为我不知道如何设置为屏幕宽度的80%。
<fragment
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/xFragment"
android:name="com.example.x.x.xFragment"/>
谢谢
将片段放在线性布局中,类似的东西:
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10">
<fragment
android:layout_width="0dp"
android:layout_weight="8"
android:layout_height="fill_parent"
android:id="@+id/xFragment"
android:name="com.example.x.x.xFragment"/>
<View
android:id="@+id/otherElement"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"/>
</LinearLayout>
希望它能帮助您!
片段没有参数,例如高度,宽度,边缘。视图和视图组具有高度,宽度,边距的参数。因此,您可以调整放置片段的容器。