6

我想從支持庫中使用新的NestedScrollView。我希望可滾動內容擴大以匹配父項,如果它較小。我看到要這樣做,我應該添加fillViewport=trueNestedScrollView。當我這樣做時,我的可滾動內容不會垂直拉伸,而是橫向延伸到屏幕外。 enter image description hereAndroid NestedScrollView fillViewport拉伸不正確

佈局card_movie簡單地有一個RelativeLayout與一些TextViews和一個ImageView裏面。沒什麼特別的。 enter image description here

回答

13

我已經用它是這樣的:

<android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      ... 

也許不同的是,線性佈局有一個指定的方向或者也許我用更多更新的庫com.android.support:design:23.1.0,這就是爲什麼我不能重現的原因你的問題。

+0

熱潮!我就是這個意思! – worked

1

也許我是最適合這個爲時已晚,但我解決了這個方式是與padding更換NestedScrollView孩子(在你的情況,RelativeLayoutmargin。如果不起作用,請嘗試用padding代替RelativeLayout子代margin

讓我知道,如果這有效!