我想在单击我的AlertDialog时显示一个RatingBar,但是问题是RatingBar仍可缩放(仍然可以更改等级)。

我希望我可以单击RatingBar,但不能缩放它。

在这种情况下

<RatingBar
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="?android:attr/ratingBarStyleSmall"
                    android:isIndicator="false"
                    android:theme="@style/RatingBar"
                    android:rating="5"
                    android:layout_marginTop="2dp"
                    android:id="@+id/showrating"
                    />


单击RatingBar是可能的,但也可以缩放。

在这种情况下

<RatingBar
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="?android:attr/ratingBarStyleSmall"
                    android:isIndicator="true"
                    android:theme="@style/RatingBar"
                    android:rating="5"
                    android:layout_marginTop="2dp"
                    android:id="@+id/showrating"
                    />


无法缩放,但也无法单击。


  在两种情况下,我都达不到我想要的。


我对android:isIndicator=""有问题

最佳答案

您可以做的是将RatingBar包装在FrameLayout中:

<FrameLayout
        android:id="@+id/frame"
        android:clickable="true"
        android:focusable="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:onClick="onClick">
        <RatingBar
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="?android:attr/ratingBarStyleSmall"
                    android:isIndicator="true"
                    android:theme="@style/RatingBar"
                    android:rating="5"
                    android:layout_marginTop="2dp"
                    android:id="@+id/showrating"
                    />
</FrameLayout>


然后将AlertDialogue逻辑放入onClick方法中:

public void onClick(View v){
        //AlertDialogue Logic
}

08-18 05:43
查看更多