gpt4 book ai didi

android - 如何给评级栏星之间的间距 android?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:56:31 24 4
gpt4 key购买 nike

您好,我正在使用带有自定义图像的自定义评级栏。我需要在星星之间提供空间。当我增加最小高度和最大高度时,星形图像保持不变。

   <RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="5dp">

<TextView
android:id="@+id/allreviews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Rating"
android:layout_marginLeft="8dp"
android:textSize="14sp" />

<RatingBar
android:id="@+id/reviewallrating"
style="@style/customRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/allreviews"
android:isIndicator="false"
android:numStars="5"
android:stepSize="0.1" />

</RelativeLayout>

样式: @drawable/star_rating_bar_full 12dip 12dip

   star_rating_bar_full.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+android:id/background"
android:drawable="@drawable/star_ratingbar_full_empty" />
<!-- <item android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/star_ratingbar_full_empty" /> -->
<item android:id="@+android:id/progress"
android:drawable="@drawable/star_ratingbar_full_filled" />
</layer-list>

star_ratingbar_full_empty:

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

<!-- This is the rating bar drawable that is used to
show a filled cookie. -->
<selector
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/star_gray" />

<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/star_gray" />

<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/star_gray"/>

<item android:drawable="@drawable/star_gray" />

</selector>
star_ratingbar_fullfilled.xml:

  <item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/yellow_star" />

<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/yellow_star" />

<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/yellow_star" />

<item android:drawable="@drawable/yellow_star" />

我在样式中使用了 style="?android:attr/ratingBarStyle"但输出仍然保持不变。 enter image description here

最佳答案

您可以简单地在 PNG 的左侧和右侧添加一些空白区域。

也就是说,在 GIMP(或您使用的任何图形编辑器程序)中增加灰色和黄色 PNG 的宽度。
只是 Canvas ,没有拉伸(stretch)星形图标。

关于android - 如何给评级栏星之间的间距 android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27815434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com