2017-01-05 48 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

通過將工具欄放置在滾動視圖之外,滾動不會影響工具欄。

您需要周圍添加工具欄&滾動視圖這樣一個額外的LinearLayout。

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