0

その中に3つのtextViewを含むリストビューを設計しようとしています。1 つのテキストビューは作成者用、2 つ目は日付用、最後のテキストビューはコメント用です。しかし、レイアウトに問題があり、XML の怪物ではありません。だから私はいくつかのアドバイスが必要です。これは私のリストが atm のように見えるものです: http://tinypic.com/view.php?pic=357khhj&s=6

ご覧のとおり、誰かが 2 つ以上の単語 (jesper のコメントなど) を入力すると、すべてがひどいものに見えます。写真のように行がすべて狂わずにこれを修正する方法はありますか? また、コメントに2行のテキストしか表示できないようにしたいのですが、実際に入力したとしても、例として10行としましょう。ありがとう!

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

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff" >

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:weightSum="1.0" >

    <TableRow>

        <TextView
            android:id="@+id/feedback_list_item_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:layout_weight="0.8"
            android:gravity="left"
            android:shadowColor="#bdbebd"
            android:shadowDx="1.0"
            android:shadowDy="1.0"
            android:shadowRadius="0.5"
            android:text="Unknown"
            android:textColor="#000000"
            android:textSize="16dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/feedback_list_item_time"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:layout_weight="0.2"
            android:gravity="right"
            android:shadowColor="#bdbebd"
            android:shadowDx="1.0"
            android:shadowDy="1.0"
            android:shadowRadius="1.0"
            android:text="00:00"
            android:textColor="#3c6dae"
            android:textSize="16dp" />
    </TableRow>

    <TableRow>

        <TextView
            android:id="@+id/feedback_list_item_comment"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:shadowColor="#cccccc"
            android:shadowDx="1.0"
            android:shadowDy="1.0"
            android:shadowRadius="0.5"
            android:text="No comment"
            android:textColor="#222222"
            android:textSize="16dp" />
        >
    </TableRow>
</TableLayout>

</LinearLayout>
4

2 に答える 2

0

テーブルの各行にRelativeLayoutを使用します。たとえば、2つのTableRowの代わりに次のコードを試してください。

<RelativeLayout
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/feedback_list_item_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="5dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:gravity="left"
        android:shadowColor="#bdbebd"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="0.5"
        android:text="Unknown"
        android:textColor="#000000"
        android:textSize="16dp"
        android:textStyle="bold"
        android:lines="1"/>

    <TextView
        android:id="@+id/feedback_list_item_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:gravity="right"
        android:shadowColor="#bdbebd"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="1.0"
        android:text="00:00"
        android:textColor="#3c6dae"
        android:textSize="16dp" />

    <TextView
        android:id="@+id/feedback_list_item_comment"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="5dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/feedback_list_item_name"            
        android:shadowColor="#cccccc"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="0.5"
        android:text="No comment"
        android:textColor="#222222"
        android:textSize="16dp"
        android:maxLines="2" />

</RelativeLayout>

また、コメントTextViewにmaxLines = "2"を追加すると、2行に制限されます。

于 2012-06-19T15:12:22.993 に答える
0

これを試してください

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:singleLine="true" />

</LinearLayout>
于 2012-06-19T15:43:56.083 に答える