我在屏幕顶部有一个应用栏,我有一个带有两个按钮和textView的线性布局。这个线性布局在工具栏内部,我无法找出原因。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.stuff.stuff.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:orientation="horizontal">
<ImageButton
android:layout_height="20dp"
android:layout_width="20dp"
android:background="@drawable/arrow_left"
android:id="@+id/leftDateButton"
/>
<TextView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_weight="1"
android:id="@+id/dateBox"
/>
<ImageButton
android:layout_height="20dp"
android:layout_width="20dp"
android:background="@drawable/arrow_right"
android:id="@+id/rightDateButton"
/>
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="563dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
您可以在顶部的栏中看到两个箭头。我想把那些放在酒吧下面。
答案 0 :(得分:0)
将 AppBarLayout 元素中的所有布局项目包含在
中<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:orientation="horizontal">
<ImageButton
android:layout_height="20dp"
android:layout_width="20dp"
android:background="@drawable/arrow_left"
android:id="@+id/leftDateButton"
/>
<TextView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_weight="1"
android:id="@+id/dateBox"
/>
<ImageButton
android:layout_height="20dp"
android:layout_width="20dp"
android:background="@drawable/arrow_right"
android:id="@+id/rightDateButton"
/>
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="563dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
答案 1 :(得分:0)
我只需要添加
app:layout_behavior="@string/appbar_scrolling_view_behavior"
到线性布局