0

コードは次のとおりです。

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

今。TextView (スクロール可能なビュー内) にかなり長いテキストを入れたとき。歪みの問題が発生します。テキストの上部が切り取られます。(目標は、タイトルを作成し、その下に、サーバーからの html テキスト用のスクロール可能なコンテナー (html コード) を作成することです)。

IDは問題ではありません.html文字列をプレーン文字列に配置するか、サーバーからデータを取得するか、ハードコードします。あらゆる組み合わせを試しましたが、解読できません。

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

何も役に立ちません。

4

2 に答える 2

1

問題はこの行にあります: android:layout_gravity="center_vertical|right"

于 2012-11-05T14:42:42.037 に答える
0

質問を誤解しているかもしれませんが、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>
于 2012-11-05T14:41:46.437 に答える