2016-11-02 26 views
0

私は画面の上部にアプリケーションバーがあり、私は2つのボタンと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> 

enter image description here

あなたは上部のバーに2つの矢印を参照することができます。私はバーのすぐ下にそれらを取得しようとしています。

答えて

0

内部AppBarLayout要素の後に私はちょうど私がレンダリング中に発生した例外を取得する線形レイアウト

0

すべてのレイアウト項目を囲み

<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> 
+0

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

を追加する必要がありました: ScrollViewは直接の子を1つしかホストできません。 –

+0

ビューページャと線形レイアウトを親線形レイアウトに入れて、私の答えを更新します –

関連する問題