Different size Drawable when loading as background from / drawable -hdpi instead of / drawable

I moved files with 9 patches from /drawable to /drawable-hdpi because the error log recommended using drawable-* to create density-optimized images.

The problem is that AppWidget now looks different. When Drawables saved in /drawable-hdpi , the border becomes thicker.

For more information, compare the attached screenshots. What is the reason for this difference?

Screenshot

enter image description here

Markup

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

Hard @drawable/widget_bg_default

enter image description here

widget_bg (saved to /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> 
+4
source share
1 answer
+1
source

Source: https://habr.com/ru/post/1399560/


All Articles