2017-01-05 3 views
1

Ich habe eine Aktivität mit einer Symbolleiste, die versteckt, wenn ich den Bildlauf blättern, aber der Inhalt ist nicht viel größer als ein Telefonbildschirm, so dass ich das Ausblenden der Symbolleiste deaktivieren möchte, da das macht keinen Sinn. Wie mache ich das?Deaktivieren Symbolleiste kollabiert beim Scrollen

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/svCreateAdvert" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fillViewport="true"> 

    <RelativeLayout 
     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="wrap_content" 
     android:background="@color/grey" 
     android:orientation="vertical" 
     tools:context=".CreateAdvert"> 

     <LinearLayout 
      android:id="@+id/create_advert_container_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/createAdvertToolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 

       app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 
     </LinearLayout> 

     ... 

    </RelativeLayout> 
</ScrollView> 
+1

Platzieren Sie die Symbolleiste außerhalb Ihrer Scrollview? –

Antwort

0

Wenn Sie die Symbolleiste außerhalb Ihrer Scrollview platzieren, wirkt sich das Scrollen nicht auf die Symbolleiste aus.

Sie müssen ein zusätzliches lineares Layout um die Symbolleiste & scrollview so hinzufügen.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/create_advert_container_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/createAdvertToolbar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <ScrollView 
     android:id="@+id/svCreateAdvert" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true"> 

     <RelativeLayout 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="wrap_content" 
      android:background="@color/grey" 
      android:orientation="vertical" 
      tools:context=".CreateAdvert"> 

     </RelativeLayout> 
    </ScrollView> 
</LinearLayout> 
Verwandte Themen