我们可以用滚动型中的LinearLayout里面? [英] Can we use a ScrollView inside a LinearLayout?
本文介绍了我们可以用滚动型中的LinearLayout里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要设计一个GUI与下面的顶端部分,做涡旋在不滚动屏幕的顶部内容,和内容。我想过使用的LinearLayout对于非滚动的部分,滚动型的滚动一部分。然而,当我尝试的LinearLayout后使用滚动型我得到一个运行时错误。是否有可能到的LinearLayout和滚动型添加到父母的LinearLayout?
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 scroll. 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?
推荐答案
可以
<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>
这篇关于我们可以用滚动型中的LinearLayout里面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文