我想制作可滚动的布局,因为我的TextView有很长的文字。我搜索并找到了一些解决方案,比如在RelativeLayout中创建一个ScrollView并在那里创建另一个RelativeLayout。并改变了我的xml代码。但什么都没发生。
这是我的xml代码:
<RelativeLayout 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="com.example.arsh.fina.IntroActivity">
<include layout="@layout/content"/>
<ScrollView
android:layout_marginTop="55dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_parent"
android:layout_marginTop="55dp">
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:adjustViewBounds="true"
app:srcCompat="@drawable/surv1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_below="@+id/imageView3"
android:layout_marginTop="20dp"
android:textColor="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A VERY
VERY
VERy
VERY TEXT"/>
</RelativeLayout>
</ScrollView>
<android.support.v4.widget.DrawerLayout
android:id="@+id/a1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp">
<android.support.design.widget.NavigationView
android:id="@+id/a2"
android:layout_gravity="right"
android:layout_height="match_parent"
android:layout_width="180dp"
app:headerLayout="@layout/header"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
我哪里出错?
答案 0 :(得分:0)
这适用于设备。它可能不会在你的结尾滚动的原因是因为没有什么可以使用你提供给我们的代码滚动。意思是你的textivew不够长
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="com.vzw.www.deviceid.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="55dp">
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#cdcdcd"
android:layout_marginTop="13dp"
android:adjustViewBounds="true"
android:layout_alignParentTop="true" />
<TextView
android:layout_below="@+id/imageView3"
android:layout_marginTop="20dp"
android:textColor="#000000"
android:textSize="50sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="A VERY
VERY
dfsdfdsf
sdf
dsfsdfsd
fds
fsdfsdf
sdf
sdf
sd
fsd
f
sdf
sdf
sdf
sdf
sd
fsd
f
sd
fsd
fds
fs
df
sd
fsd
fsd
f
sd
fsd
f
sdf
sd
f
VERy
VERY TEXT"/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>