I need to design a GUI with content at the top of the screen that doesn't scroll, and content below the top part that does sc开发者_运维知识库roll. I thought about using a LinearLayout for the non-scrolling part and ScrollView for the scrolling part. However, when I try to use ScrollView after a LinearLayout I get a runtime error. Is it possible to add a LinearLayout and a ScrollView to a parent LinearLayout?
You can
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<!-- non-scrolling top pane -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This text will not scroll"
/>
</LinearLayout>
<!-- scrolling bottom pane -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This text will scroll if it is long enough..."
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
精彩评论