【发布时间】:2017-04-10 17:43:49
【问题描述】:
如您所见,放在Toolbar 中的LinearLayout 向右移动...
因此,Toolbar 不能很好地与 TabHost 叠加(这再次通过父 Fragment 中的 Toolbar 实现)。
- 我该如何解决?
布局草图(Android Studio)
实际应用
布局代码
<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"
tools:context="com.android.example">
<android.support.v7.widget.RecyclerView
android:id="@+id/recview_navigator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:layout_weight="1"/>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/accent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_navigator"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView_navigator_up"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/ic_navigate_before_white_48dp"
android:tint="@color/recview"/>
<ImageView
android:id="@+id/imageView_navigator_save"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/ic_save_white_48dp"
android:tint="@color/recview"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
【问题讨论】:
-
如果您不打算使用
AppBarLayout或Toolbar从布局中删除它们。
标签: android android-layout material-design android-toolbar