【问题标题】:Fragment loads a Fragment in a linear layout, doesn't apply the weight片段以线性布局加载片段,不应用权重
【发布时间】:2017-09-28 14:13:27
【问题描述】:

我的问题是:

我有一个片段,它使用具有“权重”属性的线性布局加载另一个片段。

<LinearLayout
    android:id="@+id/linear"
    android:layout_width="match_parent"
    android:layout_weight="8"
    android:orientation="horizontal"
    android:layout_height="0dp">
</LinearLayout>

但是,当片段加载时,它不会应用属性权重。 在我的第二个片段中,我有这样的视图:

inflater.inflate(R.layout.activity, container, false);

我能做什么?

【问题讨论】:

  • 我认为应该将权重应用于包含片段的框架布局。

标签: android android-fragments android-linearlayout android-framelayout android-layout-weight


【解决方案1】:

将方向从水平更改为垂直,这段代码将起作用。

<LinearLayout android:id="@+id/linear" android:layout_width="match_parent" android:layout_weight="8" android:orientation="vertical" android:layout_height="0dp"> </LinearLayout>

【讨论】:

    猜你喜欢
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-20
    • 2017-04-15
    • 2017-04-09
    • 1970-01-01
    相关资源
    最近更新 更多