加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 如何将滚动视图添加到整个活动?

发布时间:2020-12-15 02:47:56 所属栏目:Java 来源:网络整理
导读:我尝试在活动布局上的所有内容周围添加滚动视图,但它给了我一个错误,说它只能放在一件事上. 我的活动,有一个标题textview然后是一个图像,然后是一个描述文本视图,你无法阅读整个描述,因为它很长并且低于我的屏幕边缘.如何让whoel事物可滚动? 我的xml看起来
我尝试在活动布局上的所有内容周围添加滚动视图,但它给了我一个错误,说它只能放在一件事上.

我的活动,有一个标题textview然后是一个图像,然后是一个描述文本视图,你无法阅读整个描述,因为它很长并且低于我的屏幕边缘.如何让whoel事物可滚动?

我的xml看起来像这样:

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


    <TextView
        android:id="@+id/beerTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:textSize="40sp"
        android:textStyle = "bold"
        >
    </TextView>

    <ImageView android:id="@+id/image"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_margin="10dip"/>

    <Button
        android:id="@+id/buttonBrewery"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="" />
    <Button
        android:id="@+id/buttonStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="" />

    <TextView
        android:id="@+id/beerDEscriptionTitle"
        android:textStyle = "bold"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:textSize="20sp"
        android:text="Description"
        ></TextView>
    <TextView
        android:id="@+id/beerDescription"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:textSize="15sp"

        ></TextView>

</LinearLayout>

解决方法

试试这个:
<?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:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

        <!-- TextView and other stuff -->

    </LinearLayout>
</ScrollView>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读