【问题标题】:Android custom rating bar image size problemAndroid自定义评分栏图片大小问题
【发布时间】:2011-05-03 02:29:52
【问题描述】:

我正在构建一个自定义评分栏。在 kozyr 的文章的帮助下,我创建了它。 但是我对不同屏幕类型的不同图像缩放大小有疑问。 下面我在左侧提供了我的自定义评分栏的屏幕截图,在右侧提供了简单的 imageview。 这是用于 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>

【问题讨论】:

    标签: android


    【解决方案1】:

    尝试使用设备独立像素而不是实际像素。例如:

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

    请参阅the docs 了解此主题。

    【讨论】:

    • 不幸的是,它没有帮助
    【解决方案2】:

    问题解决了。当我添加

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

    到清单文件一切都好了)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-18
      • 2012-12-24
      • 1970-01-01
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多