是否有一个Android TextVew窗口小部件XML属性,可以从字符串的底部显示



我有一个textview窗口小部件,在我的程序中,我总是必须向下滚动到文本的底部才能查看文本字符串的最后元素。

文本太大而无法放在一个屏幕上,所以很明显,我将其设置为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>

您可以在活动中使用以下内容:

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

我不确定会这样做的XML属性。

最新更新