2017-04-05 156 views
0

我在content_main中使用導航抽屜活動時會出現一個線性佈局,它將與片段一起膨脹。在其他視圖的滾動中隱藏視圖

content_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<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:id="@+id/content_home" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="net.techdesire.khabargujarat.HomeActivity" 
    tools:showIn="@layout/app_bar_home"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/fragment_container"/> 

</RelativeLayout> 

fragment_home.xml

<android.support.percent.PercentRelativeLayout 
    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" 
    tools:context="fragment.HomeFragment"> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      app:layout_heightPercent="40%"/> 


     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:padding="5dp" 
      app:layout_heightPercent="60%" 
      android:layout_below="@+id/viewpager"> 

      <TextView 
       android:id="@+id/about" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="5dp" 
       android:text="@string/about_khijadiya" 
       android:textAppearance="@style/TextAppearance.AppCompat.Large"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/about" 
       android:text="@string/dummy" 
       android:textAppearance="@style/TextAppearance.AppCompat.Medium"/> 
     </RelativeLayout> 
</android.support.percent.PercentRelativeLayout> 

我有一個名爲約TextView中大內容。我想讓它滾動,就像image.First首先滾動相關圖層到全屏,如果about的內容仍然溢出,那麼只能製作關於textview的滾動條。當滾動到達頂部時,如果用戶從那裏向下滑動,然後重新顯示viewpager。

enter image description here

+0

我不明白你想要什麼。你能試着解釋另一種方式嗎? –

回答

0

我想,你的要求是崩潰的觀點,同時滾動。

所以你可以使用 「android.support.design.widget.CollapsingToolbarLayout」。

它在材料設計中實施。

您可以參考以下鏈接: http://www.androidhive.info/2016/05/android-working-with-card-view-and-recycler-view/

+0

是的,它是這樣的,但不完全一樣。我不想操縱工具欄和其他東西。我可以只改變一個XML文件嗎? –

+0

是的,但這取決於你的觀點。 –

相關問題