2016-11-02 2 views
0

Ich habe eine App-Leiste am oberen Rand des Bildschirms, und ich habe ein lineares Layout mit zwei Tasten und einem TextView. Dieses lineare Layout ist innerhalb der Werkzeugleiste und ich kann nicht herausfinden warum.Moving Android-Layouts

<?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

Sie können an der Spitze die beiden Pfeile in der Bar sehen. Ich versuche, die unter der Bar zu bekommen.

Antwort

0

nur

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

an den linearen Layout

0

beilegen alle Layout-Elemente nach dem AppBarLayout Element innerhalb eines Ich hatte

<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

I Ausnahme während des Renderings angehoben bekommen hinzuzufügen: ScrollView kann nur ein direktes Kind hosten. –

+0

Setzen Sie den Ansichtspager und das lineare Layout in ein übergeordnetes lineares Layout. Ich werde meine Antwort aktualisieren –