Android文本太长,无法滚动视图



这是代码;

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bghome" >
    <TableRow>
        <TextView
            android:id="@+id/TextTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:gravity="center"
            android:text="Wrocław"
            android:textColor="#FFFFFF"
            android:textSize="20dp" />
    </TableRow>
    <TableRow>
        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="400dp"
            android:layout_marginLeft="10dp" >
            <TextView
                android:id="@+id/TextMain"
                android:layout_width="300dp"
                android:layout_height="400dp"
                android:layout_gravity="center_vertical|right"
                android:text="Ładowanie danych..." >
            </TextView>
        </ScrollView>
    </TableRow>
</TableLayout>

现在。当我在文本视图中放置相当长的文本(内部可滚动视图)。我会遇到失真问题。文本的顶部被削减了。(目标是创建一个标题,然后在其下面创建一个可滚动的容器,用于Serwer的HTML文本-HTML代码)。

ID没关系,我将HTML字符串放在普通字符串上,或者我从Serwer或硬码中获取数据。我尝试了每种组合,但我无法破解。

MainText.setText(Html.fromHtml(Plain_str));
MainText.setText(Plain_str);
MainText.setText(Plain_str.toString());

没有任何帮助。

问题在此行中:android:layout_gravity =" center_vertical | right"

i可能会误解这个问题,但是您是否尝试将TableRow高度设置为400dp,然后将match_parent设置为ScrollViewTextView?我对这个布局高度有问题,直到我进行了更改,然后似乎一切正常。

类似的东西:

<TableRow
    android:layout_width="match_parent"
    android:layout_height="400dp" >
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="10dp" >
        <TextView
            android:id="@+id/TextMain"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|right"
            android:text="this is very long text that is going in a textview wrapped by a scrollview. I want to see how the text is displayed when wrapped. this is very long text that is going in a textview wrapped by a scrollview. I want to see how the text is displayed when wrapped." >
        </TextView>
    </ScrollView>
</TableRow>

最新更新