2017-07-26 48 views
2

我有一個包含如何使的LinearLayout滾動沒有放在裏面滾動型

textView 
imageView 
Horizontal recyclerview 
TextView 
Horizontal Recyclerview 
Webview 

如何使它scrollable一個linearlayout沒有放在裏面scrollview

+0

你爲什麼要這樣做 – codecrazer

+0

由於我的recyclerview包含圖像,它不是回收項目,如果我把它放在滾動視圖。所以造成內存不足。 –

+0

有人可以幫忙嗎? –

回答

0

製作的LinearLayout滾動沒有如果你只使用線性佈局內的一個ListView使用滾動型

,那麼你就需要使用scrollview.Because ListView控件是滾動的default.But如果您有其他組件那麼你可以在另一個scrollview中分開它們。確保ScrollView只使用一個直接的子佈局。以下是一個示例代碼。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:background="#ffffff"> 

    <ListView 

    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:cacheColorHint="#00000000"/> 

</LinearLayout> 
0

你不行。線性佈局的設計不是將其內容滾動 - 只能通過將其嵌入到FrameLayout(或一個子類的ScrollView)中來進行滾動/平移。爲什麼不是ScrollView的一個選項?

順便說一句,垂直滾動容器內的水平滾動容器不能提供良好的用戶界面/用戶體驗,但還有其他方法可以實現您的目標。請給我們更多的細節,我敢肯定,我們將能夠幫助你

相關問題