gpt4 book ai didi

android 评分栏 xml 和 numStars

转载 作者:太空宇宙 更新时间:2023-11-03 12:38:32 24 4
gpt4 key购买 nike

我是使用 XML 进行设计的初学者 :D这是我的评分栏和 friend 的 XML:

 <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2" >

<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="#336699"
android:textSize="18dp"
android:textStyle="bold" />

<RatingBar
android:id="@+id/rtbHighScore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:numStars="5"
android:max="100"
android:rating="0.0"
android:stepSize="0.0"
style="?android:attr/ratingBarStyleSmall"
android:layout_weight="1" />

<ImageView
android:id="@+id/imgRow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical"
android:src="@drawable/rightarrow" />
</LinearLayout>

android:numStars 是 5,但这是我得到的:

enter image description here

我读到 layout_width 必须是 wrap_content 所以评级栏星星将跟随我的 android:numStars 这就是我得到的我将其更改为 wrap_content :

enter image description here

我想在 TextView 的右侧(或右箭头图像的左侧)创建 5 星评级栏谢谢:D

最佳答案

使用此布局文件获得适当的 5 星。

<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="#336699"
android:textSize="18dp"
android:textStyle="bold" />

<RatingBar
android:id="@+id/rtbHighScore"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginRight="45dp"
android:max="5"
android:numStars="5"
android:rating="0.0"
android:stepSize="0.0" />

<ImageView
android:id="@+id/imgRow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical"
/>

我认为 android:gravity="center_vertical"是问题所在。

关于android 评分栏 xml 和 numStars,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12724376/

24 4 0