2017-01-05 5 views
1

У меня есть активность с панелью инструментов, которая скрывается при прокрутке прокрутки, однако содержимое не намного больше, чем экран телефона, поэтому я хочу отключить скрытие панели инструментов, поскольку это не имеет никакого смысла. Как мне это сделать?Отключить панель инструментов при прокрутке

<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

Разместите панель инструментов вне своего прокрутки? –

ответ

0

Поместив панель инструментов за пределы прокрутки, прокрутка не повлияет на панель инструментов.

Вам нужно будет добавить дополнительную линейную паузу вокруг панели инструментов & scrollview вот так.

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