简体   繁体   English

从/ drawable-hdpi而不是/ drawable加载为背景时,不同大小的Drawable

[英]Different size of Drawable when loaded as background from /drawable-hdpi instead of /drawable

I moved 9-patch files from /drawable to /drawable-hdpi because the error log recommended to use drawable-* to offer density optimized images. 我将9-patch文件从/drawable/drawable-hdpi因为错误日志建议使用drawable-*来提供密度优化的图像。

The problem is, that the AppWidget now looks different. 问题是, AppWidget现在看起来不同了。 When Drawables are stored in /drawable-hdpi the border is thicker. Drawables存储在/drawable-hdpi ,边框更粗。

For more information compare the attached screenshots. 有关更多信息,请比较附加的屏幕截图。 What is the reason for this difference? 造成这种差异的原因是什么?

Screenshot 截图

在此输入图像描述

Layout 布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget_parent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/widget_bg" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/widget_loading"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ProgressBar
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginRight="4dp"
        android:layout_toLeftOf="@+id/textView1" />

</RelativeLayout>

Drawable @drawable/widget_bg_default Drawable @drawable/widget_bg_default

在此输入图像描述

widget_bg (stored in /drawables ) widget_bg (存储在/drawables

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/widget_bg_default" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
    <item android:drawable="@drawable/widget_bg_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/ic_launcher" android:state_selected="true"/>
    <item android:drawable="@drawable/widget_bg_focused" android:state_focused="true"/>

</selector>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM