ImageView is pixelated on older Android devices

Problem

I have an ImageView in my XML:

                <ImageView
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:src="@drawable/ic_person_add"
                android:alpha="0.87" />

ic_person_addis the normal design of Vectoricon material .

On my Nexus 5 (Android 6) the icon is beautifully beautiful and really sharp:

Nexus 5

In note 2 (Android 4.4), however, the icon becomes really pixelated and ugly:

Note 2

How can I get an ImageView (with a vector like src) on each device? Preferably with a single xml solution.

I already found:

  • Adding -> android:adjustViewBounds="true"did nothing
  • ImageView images appear pixelated and low quality → Does not apply to vector
  • Settings -> BitmapFactory.inscaled=falsedoes not work only with xml, and I did not know where to put it in the custom ImageView class.
+4
2

DPI Note 2, Android.

Melllvar :

, res/drawable, Gradle PNG API 20

, Android 6 Vectorgraphic ImageView, . 2 ( Android 5) Android Studio Vectorgraphic Drawables PNG.

PNG VectorXML,

android:height android:width

dp pre API 20. ( 100dp) :

<vector android:height="100dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="100dp">
+7

Nexus 5 xxhdpi, 2 ( this) - xhdpi. , xxhdpi (, , ), xhdpi - .

Android, .

, , , .

+1

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


All Articles