您好我的自定义主/流布局,但平板电脑无法正常工作。
我的ListActivity布局是:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/item_list"
android:name="it.package.ItemListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context="it.package.ItemListActivity"
tools:layout="@layout/list_custom_content"
/>
</LinearLayout>
我的详细布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/item_detail_container"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context="it.package.ItemDetailActivity"
tools:ignore="MergeRootFrame" />
</LinearLayout>
对于平板电脑,TwoPane布局是:
<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:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal" android:orientation="horizontal"
android:showDividers="middle"
tools:context="it.package.ItemListActivity">
<!--
This layout is a two-pane layout for the Items
master/detail flow.
-->
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default" />
<fragment android:id="@+id/item_list"
android:name="it.unifi.package.ItemListFragment"
android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"
tools:layout="@layout/list_custom_content" />
<FrameLayout android:id="@+id/item_detail_container" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_weight="3" />
</LinearLayout>
对于智能手机一切正常,但在平板电脑我有白页..
答案 0 :(得分:1)
试试这个:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal"
android:orientation="horizontal"
android:showDividers="middle"
android:layout_below="@+id/toolbar_actionbar"
tools:context="it.package.ItemListActivity">
<fragment
android:id="@+id/item_list"
android:name="it.package.ItemListFragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:layout="@layout/list_custom_content" />
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_color"
android:minHeight="?attr/actionBarSize" />
</RelativeLayout>