0

アプリケーションで 4 列の TableLayout を使用しています。評価バーを連続して挿入するとlayout_span=3、星が期待どおりに機能しません。

例として をつけましたが、6つ星の2/3numStars=5を示しています。また、3 番目の星をクリックすると 3.25 の星が選択され、4 番目を選択すると 4.5 が強調表示されます... スケーリングが正しく機能していません。

layout_height を wrap_content に変更してみましたが、結果は同じです。layout_span を削除した場合にのみ正常に動作しますが、その場合、他の行の列に歪みがあります。

何が問題なのか、誰でも助けてもらえますか? これが通常の動作である場合、layout_span で適切な評価バーを取得するにはどうすればよいですか?

<TableRow
            android:layout_width="wrap_content"
            android:layout_height="0dp"
        android:layout_weight="1" >

        <TextView
                android:id="@+id/rating"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/rating" />

        <RatingBar
                android:id="@+id/add_rating"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_span="3"
                android:numStars="5"
                android:stepSize="1"
                android:rating="4" />

    </TableRow>
// NORMAL ROW
<TableRow
            android:id="@+id/tr12"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
        android:layout_weight="1" >
            <TextView
                android:id="@+id/lab_datepurchased"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/datepurchased" />

            <EditText
                android:id="@+id/add_datepurchased"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="@string/dateinput" />

            <TextView
                android:id="@+id/lab_shelfno"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/shelfno" />

            <EditText
                android:id="@+id/add_shelfno"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="@string/definputtext2" />

        </TableRow>
4

1 に答える 1

1
// try this
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/banner_holder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center">

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center">

        <TextView
            android:id="@+id/rating"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="rating" />

        <RatingBar
            android:id="@+id/add_rating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="5"
            android:stepSize="1"
            android:rating="4" />
    </TableRow>

    <TableRow
        android:id="@+id/tr12"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center">
        <TextView
            android:id="@+id/lab_datepurchased"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:text="@string/datepurchased" />

        <EditText
            android:id="@+id/add_datepurchased"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="@string/dateinput" />

        <TextView
            android:id="@+id/lab_shelfno"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:text="@string/shelfno" />

        <EditText
            android:id="@+id/add_shelfno"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="@string/definputtext2" />

    </TableRow>
</TableLayout>
于 2013-11-11T04:48:28.277 に答える