【发布时间】:2017-06-11 12:16:40
【问题描述】:
下面的布局文件应该给你一个想法,我想要 TextView 下方的 RelativeLayout 内的滚动视图的内容,但是 ScrollView 的内容走出 RelativeLayout 隐藏在 TextView 后面。我不明白这是怎么回事。在 ScrollView 内的 RelativeLayout 中,我以编程方式添加了一个 LinearLayoutCompat 对象,并且我还以编程方式向该对象添加了几个 AppCompatTextView 对象。屏幕截图只是布局的 1 个实例。
我将嵌套的 RelativeLayout 设置为从 TextView 下方开始,但它仍然从最顶部开始。
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/narrowTextnon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/cherryRed"
android:elevation="8dp"
android:gravity="center"
android:layout_marginTop="15dp"
android:padding="25dp"
android:text="Let's narrow down now !"
android:textColor="@color/wineBrown"
android:textSize="22sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/narrowTextnon"
android:gravity="center">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/dataContnon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
标签: android android-layout scrollview android-scrollview