2014-01-30 2 views
1

내 프로그램에서 텍스트 문자열의 마지막 요소를 보려면 항상 텍스트의 맨 아래로 스크롤해야하는 텍스트 뷰 위젯이 있습니다.문자열의 맨 아래에서 표시 할 Android TextVew 위젯 XML 속성이 있습니까

텍스트가 너무 커서 한 화면에 표시되지 않으므로 분명히 scrollview 개체로 설정해야합니다.

내가 원했던 것은 textview 위젯이 기본적으로 텍스트 하단을 표시하는 반면 사용자는 아래로 스크롤해야하는 상단부터 시작하여 현재의 기본 표시가 아닌 상단을 보려고 스크롤하는 것입니다 큰 끈의 바닥을보십시오.

내 xml 파일은 다음과 같습니다

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <View 
     android:layout_width="fill_parent" 
     android:layout_height="10dp" > 
    </View> 

    <ScrollView 
     android:id="@+id/ScrollView01" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="500" 
     android:fillViewport="true" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="300dp" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/InfoText" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/hugeMultiLineString" 
       android:layout_gravity="bottom" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 
    </ScrollView> 

    <View 
     android:layout_width="fill_parent" 
     android:layout_height="10dp" > 
    </View> 

    <TableLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     tools:ignore="UselessParent" > 

     <TableRow> 

      <Button 
       android:id="@+id/export" 
       style="@style/AppTheme" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Export" /> 

      <Button 
       android:id="@+id/importFromRemote" 
       style="@style/AppTheme" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Import" /> 

      <Button 
       android:id="@+id/dirlist" 
       style="@style/AppTheme" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Dirt" /> 

      <Button 
       android:id="@+id/test" 
       style="@style/AppTheme" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Test" /> 

      <Button 
       android:id="@+id/exit" 
       style="@style/AppTheme" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Exit" /> 
     </TableRow> 
    </TableLayout> 

    <View 
     android:layout_width="fill_parent" 
     android:layout_height="10dp" > 
    </View> 

</LinearLayout> 

답변

1

당신은 당신의 활동에서 다음 사용할 수 있습니다

scrollView = (ScrollView) findViewById(R.id.ScrollView01); 
scrollView.post(new Runnable() { 
    public void run() { 
     scrollView.fullScroll(ScrollView.FOCUS_DOWN); 
    } 
}); 

나는이 작업을 수행 할 XML 속성에 대해 확실하지 않다.

+1

감사합니다. 당신의 대안이 작동합니다. 내 주요 문제는 내가 textview 특성을 수정하려고했는데, 나중에 참조 할 수 있도록 xml scrollview 특성이있을 수 있습니다. 물론, 당신의 예제는 작업을 위해 훌륭하게 작동합니다. –

관련 문제