我无法在Android Studio中创建ScrollView

xmjla07d  于 8个月前  发布在  Android
关注(0)|答案(1)|浏览(81)

我希望创建滚动视图与线性布局,其中将有textview在它(在Android Studio)。但我的滚动视图不工作。我也不能添加文本更多的AVD屏幕尺寸。我的XML代码如下:

`<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.5">

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

            <TextView
                android:id="@+id/textView"
                android:layout_width="match_parent"
                android:layout_height="723dp"
                android:padding="25dp"
                android:text="@string/textview"
                android:textSize="24sp" />
        </LinearLayout>
    </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>`


I expect my Android app to have scrollview with linearlayout and with Textview showing lengthy text which can be scrolled vertically
wz3gfoph

wz3gfoph1#

  • 用这个密码 *
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:scrollbars="none">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="Rahul"
            android:gravity="center"
            android:textSize="20sp"/>
    </LinearLayout>
</ScrollView>

相关问题