簡體   English   中英

從/ drawable-hdpi而不是/ drawable加載為背景時,不同大小的Drawable

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

我將9-patch文件從/drawable/drawable-hdpi因為錯誤日志建議使用drawable-*來提供密度優化的圖像。

問題是, AppWidget現在看起來不同了。 Drawables存儲在/drawable-hdpi ,邊框更粗。

有關更多信息,請比較附加的屏幕截圖。 造成這種差異的原因是什么?

截圖

在此輸入圖像描述

布局

<?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

在此輸入圖像描述

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