2016-06-21 57 views
0

我已经头痛了整个scrollview/textview事情几天了。我有一个包含textview的滚动视图,然后我在它下面有另一个textview(状态)。滚动查看隐藏底部文本视图

  1. 滚动/文本,一旦包含长结果文本,将下降到我的屏幕的底部,并完全隐藏自己的“身份”的TextView,这应该是始终为1线在底部我屏幕。

  2. 我想有重力,因此当文本变得更长时,滚动条自动滚动到底部,当我有新的线条。我曾尝试在“textResult”文本视图中添加gravity = bottom,但它不起作用 - 即使在文本结果中有新行(超出屏幕底部)时,滚动条也不会移动。

- 我该如何解决这个问题?非常感谢!

<?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> 

回答

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>