Scrollview隐藏底部textview

时间:2016-06-21 03:05:59

标签: android-layout textview android-scrollview android

我对这整个scrollview / textview事情感到头疼几天。我有一个包含textview的Scrollview,然后我在它下面有另一个textview(状态)。

  1. 滚动/文本,一旦包含一个长结果文本,将下拉到我的屏幕底部并完全隐藏我的“状态”文本视图,该视图应该始终位于屏幕底部的1行

  2. 我希望有重力,以便当结果文本变长时,滚动条会在我有新行时自动滚动到底部。我尝试在“textResult”文本视图中添加了一个gravity = bottom,但它不起作用 - 即使我在文本结果中有新行(超出屏幕底部),滚动条也不会移动

  3. - 我怎么能解决这个问题呢?非常感谢!

        <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff">
    
    
        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/scrollResult"
            android:fillViewport="false"
            android:layout_alignParentBottom="false">
            <TextView
                android:id="@+id/textResult"
                android:background="@drawable/back"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textIsSelectable="true"
                />
        </ScrollView>
    
        <TextView
            android:id="@+id/status"
            android:layout_width="fill_parent"
            android:editable="false"
            android:textSize="12sp"
            android:text=""
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_below="@+id/scrollResult"
            android:gravity="bottom"
            android:minLines="1"
            android:maxLines="1"
            android:singleLine="true"
            android:minHeight="20dp"
            android:maxHeight="20dp" />
    
    </RelativeLayout>
    

1 个答案:

答案 0 :(得分:0)

试试这可能会对你有所帮助

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">


<ScrollView
    android:id="@+id/scrollResult"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/status"
    android:fillViewport="false">

    <TextView
        android:id="@+id/textResult"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/back"
        android:textIsSelectable="true" />
</ScrollView>

<TextView
    android:id="@+id/status"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:editable="false"
    android:gravity="bottom"
    android:maxHeight="20dp"

    android:maxLines="1"
    android:minHeight="20dp"
    android:minLines="1"
    android:singleLine="true"
    android:text=""
    android:textSize="12sp" />

</RelativeLayout>
相关问题