0

テーブル レイアウト内の評価バーを修正できません。基本的に私が欲しいのは、他の行の配置に関係なく、その幅に正確にまたがる5つ星の評価バーを持つことです。しかし、ディスプレイに星が多かれ少なかれ表示されています。

以下では、何が起こっているのかを視覚的に説明しています。

トライアル#1:RatingBar行でlayout_spanとlinearlayoutを使用しない場合、RatingBarは2列目に配置され、4列目が大幅に切り捨てられます

ここに画像の説明を入力

試行 2 : 評価バーに layout_span=2 または 3 を使用すると、それぞれ 3 列目または 4 列目に配置されます。それが起こるたびに、ratingBar 内の星の数が増えました

ここに画像の説明を入力

Trial#3 : layout_span=3 で linearlayout を配置し、その中に ratingBar を配置すると (現在のコード)、layout_width が wrap_cotent であっても全幅が表示されません。

ここに画像の説明を入力

RatingBar には、レイアウトを強制的に他の行スパンを超えて伸ばす幅がないようです。

誰でもこれを解決する方法を教えてもらえますか?

理想的なシナリオ: Photoshop で処理したため、色の歪みが発生しました :) ここに画像の説明を入力

コード:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:background="@color/bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".AddEntry" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <TableRow
            android:padding="2.5dp"
            android:background="@color/col1"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="test1" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:hint="test2" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:text="test3" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:hint="test4" />

        </TableRow>

        <TableRow
            android:padding="2.5dp"
            android:background="@color/col2"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="test5" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_span="3"
                android:hint="test6" />

        </TableRow>

        <TableRow
            android:padding="2.5dp"
            android:background="@color/col1"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="test7" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="2"
                android:layout_marginLeft="5dp"
                android:hint="test8" />

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:src="@drawable/get_google" />

        </TableRow>

        <TableRow
            android:paddingLeft="2.5dp"
            android:background="@color/col2"
            android:gravity="center_vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="test9" />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3" >
                <RatingBar
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:numStars="5"
                    android:stepSize="1"
                    android:rating="1" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:text="" />
            </LinearLayout>
        </TableRow>
    </TableLayout>
</ScrollView>
4

1 に答える 1

0

小さな評価バーを使用することをお勧めします

 style="?android:attr/ratingBarStyleSmall"

以下のリンクも参照

5つ星を表示するRatingBarの作り方

Android で、TextView と同じ TableRow にある場合、RatingBar が正しく表示されない

于 2013-12-10T06:30:46.340 に答える