2016-06-21 54 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>