如果 ScrollView 仅支持一个直接子级,我应该如何使整个布局可滚动? [英] If ScrollView only supports one direct child, how am I supposed to make a whole layout scrollable?

查看:19
本文介绍了如果 ScrollView 仅支持一个直接子级,我应该如何使整个布局可滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个布局中有 3 个文本视图,其中文本在我的 droid 2 的底部剪辑了一点点......我如何确保整个文本都是可见的,并且用户可以向下滚动(只需用他们的手指),查看我的其余文字?

I have 3 text views in a layout, where the text clips a tad on the bottom on my droid 2... How can I ensure that the whole text is viewable, and the user can scroll down (simply with their finger), to see the rest of my text?

谢谢!

<?xml version="1.0" encoding="utf-8"?>


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

    <ImageButton android:id="@+id/ImageButton01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/def" 
    android:layout_gravity="top|center">
    </ImageButton>

<TextView android:id="@+id/oneView" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/one_def" 
android:layout_gravity="left|center" 
android:textSize="13dip"></TextView>

<TextView android:text="@string/two_def" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="left|center" 
android:id="@+id/twoView" 
android:textSize="13dip"></TextView>

<TextView android:text="@string/threedef_def" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="left|center" 
android:id="@+id/threeView" 
android:textSize="13dip"></TextView>


</LinearLayout>

推荐答案

只需用 ScrollView 包装你当前的 LinearLayout.所以应该是这样的:

Just wrap your current LinearLayout with ScrollView. So it should be smth like this:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageButton ... />
        <TextView ... />
        <TextView ... />
        <TextView ... />

    </LinearLayout>
</ScrollView>

这篇关于如果 ScrollView 仅支持一个直接子级,我应该如何使整个布局可滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆