我想添加重量參數到片段xml在android工作室,這樣我的兩個fragements可以每個半屏幕,但增加重量沒有影響佈局。什麼有趣的是,我仍然可以增加重量正常活動的意見在這裏是screen shot無法在android studio中添加重量參數到片段?
這是我的佈局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="io.designcoder.vivz.lifecycle.xml.ActivityFragmentXml">
<fragment
android:id="@+id/fragment_xml_a"
class="io.designcoder.vivz.lifecycle.xml.FragmentXmlA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:layout="@layout/fragment_xml_a"
/>
<fragment
android:id="@+id/fragment_xml_b"
class="io.designcoder.vivz.lifecycle.xml.FragmentXmlB"
android:layout_width="match_parent"
android:layout_below="@id/fragment_xml_a"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_xml_b"
/>
</RelativeLayout>
把你的片段放在LinearLayout中。並讓你的片段寬度0dp –
你的片段是在LinearLayout還是RelativeLayout中? – Natalia
請分享您的佈局文件。 – Joshua