android - 在评级栏中截断图像

标签 android

我制作了自己的评分栏。花卉图像有 4 种尺寸(xdpi、hdpi 等),从 24pxx24px 到 64x64px。

<?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/ic_rating_flowers_empty" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/ic_rating_flowers_empty" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/ic_rating_flowers" />
</layer-list>

可绘制内容中的 rating_flowers.xml

<style name="flowersRating" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/rating_flowers</item>
    <item name="android:minHeight">24dip</item>
    <item name="android:maxHeight">64dip</item>
</style>

在 styles.xml 中

<TableRow
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dip" >

    <TextView
        android:text="@string/mood_headache" />

    <RatingBar
        android:id="@+id/moodHeadacheRating"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"    
        android:numStars="3"
        android:stepSize="1.0"
        android:rating="0" 
        style="@style/flowersRating" />

 </TableRow> 

和 Activity

我所看到的

What I see

和来自 drawable-ldpi 的图片

enter image description here enter image description here

最佳答案

尝试删除

android:padding="5dip"

来自 TableRow,因为它会在 flower 可绘制对象上方产生一个填充。

关于android - 在评级栏中截断图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11864608/

相关文章:

java - Android 匿名类加载器泄漏安全吗?

java - 如何根据对象属性将列表对象生成为多个列表?

c# - iOS、Android、Windows 10 移动模拟器是否可用于使用 Visual Studio 2015 开发 Xamarin.Forms?

Android - setImageResource 比将资源 ID 解码为位图更有效吗?

android - 如何从 getItemAtPostion 方法获取 View/Widget,android?

android - 如何在 Angularjs 中下载存储在 http 服务器中的音乐

android - javax.net.ssl.SSLPeerUnverifiedException : No peer certificate while trying to connect using https with . bks keystore

javascript - 在android的 WebView 上隐藏网页的页脚

android - 堆不会在 Genymotion 模拟器上扩展

android - 如何使用 Retrofit 查看创建的 JSON 字符串