Android自定义评级栏图像大小问题

时间:2011-05-03 02:29:52

标签: android

我建立一个自定义评级栏。在kozyr的文章的帮助下,我创造了它。 但是我对不同屏幕类型的不同图像缩放大小存在问题。 下面我提供左侧自定义评级栏的屏幕截图,右侧是简单的图像视图。 这适用于HVGA屏幕。

link to screenshot

如您所见,评级栏和图像视图中的星星是相同的

来自HVGA屏幕的截图

another link to the screenshot

Android以某种方式调整了我的评级栏中的星标。有什么问题?!!

这是代码

<RatingBar android:id="@+id/rating_lunch" style="@style/starRatingBar" android:layout_width="wrap_content"
                   android:layout_height="wrap_content" android:numStars="5" android:stepSize="1.0"/>

这就是风格:

<style name="starRatingBar" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/progress_star_big</item>
    <item name="android:minHeight">19px</item>
    <item name="android:maxHeight">19px</item>
</style>

2 个答案:

答案 0 :(得分:2)

尝试使用设备无关像素而不是实际像素。 e.g:

<item name="android:maxHeight">19dp</item>

有关此主题的信息,请参阅the docs

答案 1 :(得分:2)

问题解决了。当我添加

<uses-sdk android:minSdkVersion="4"
      android:targetSdkVersion="7"   />

到清单文件,一切都变好了)

相关问题