Robson
Robson

Reputation: 1277

Android drawable item size on different resolutions

Is it possible to get correctly scaled item drawable in android layer-list item?

I prepared something like this:

bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/splash_bg" />
    <item
        android:gravity="center"
        android:drawable="@drawable/logo_white">
    </item>
</layer-list>

The sizes for drawable/logo_white vector has: 200dp width and 100dp height. It looks nice for small devices, but on tablet this logo is too small.

Is it possible to make it responsive for bigger screens?

Many thanks for help.

Upvotes: 0

Views: 58

Answers (2)

Nabil
Nabil

Reputation: 672

You can use attribute width and height in API level 23 and higher:

<item
    android:width="@dimen/your_size" android:height="@dimen/your_size"
    android:drawable="@drawable/logo_white"/>

And create different dimens files, for normal phones, tab, etc

Upvotes: 1

prasid444
prasid444

Reputation: 355

Android has multiple folder system for multiple resolutions.

layout-hdpi,
layout-xhdpi, etc.

and same goes for drawable folder too. So by implementing same filename but edited xml based on dimension for different folder you can make in responsive. You might find other different technique for this.

Upvotes: 1

Related Questions