尝试RelativeLayout
在较小的屏幕尺寸上呈现以下内容时。在图形布局编辑器中,第二个TextView
完全隐藏,但第一个完全展开,显示完整的文本内容。我知道这TextViews
应该是可滚动的。
有什么方法可以使用RelativeLayout
并给每个屏幕的相等部分,或者我应该只使用 a LinearLayout
and uselayout_weight
吗?从 Android 文档中的指导来看,我的印象是应该避免LinearLayout
使用RelativeLayout
.
<RelativeLayout
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/tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:fillViewport="true"
android:gravity="center"
android:text="Lorem ipsum dolor sit amet, onsectetur adipiscing elit. Curabitur molestie tempor ante non interdum. Nullam sit amet diam ligula. Suspendisse ultricies commodo felis in rutrum. Lorem ipsum dolor sit amet, onsectetur adipiscing elit. Curabitur molestie tempor ante non interdum. Nullam sit amet diam ligula. Suspendisse ultricies commodo felis in rutrum.Lorem ipsum dolor sit amet, onsectetur adipiscing elit. Curabitur molestie tempor ante non interdum. Nullam sit amet diam ligula. Suspendisse ultricies commodo felis in rutrum."
android:scrollbars="vertical"
android:maxlines="100"
android:textSize="22dp" >
</TextView>
<TextView
android:id="@+id/tv2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv1"
android:fillViewport="true"
android:gravity="center"
android:scrollbars="vertical"
android:maxlines="100"
android:text="Lorem ipsum dolor sit amet, onsectetur adipiscing elit. Curabitur molestie tempor ante non interdum. Nullam sit amet diam ligula. Suspendisse ultricies commodo felis in rutrum. Lorem ipsum dolor sit amet, onsectetur adipiscing elit. Curabitur molestie tempor ante non interdum. Nullam sit amet diam ligula. Suspendisse ultricies commodo felis in rutrum.Lorem ipsum dolor sit amet, onsectetur adipiscing elit. Curabitur molestie tempor ante non interdum. Nullam sit amet diam ligula. Suspendisse ultricies commodo felis in rutrum."
android:textSize="22dp" />
</RelativeLayout>