java - Scaling drawable resources -
i have done image editing of application want make fit every device scaling them different sizes. have found site put image scales different screen densities when put in project not adapt screen.
here's code:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity" android:background="@drawable/backgroundapp" android:orientation="vertical"> <imagebutton android:id="@+id/btnswitch" android:layout_width="105dp" android:layout_height="105dp" android:src="@drawable/poweroffline" android:background="@null" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="65dp" /> <imagebutton android:id="@+id/flashblinkbutton" android:layout_width="75dp" android:layout_height="75dp" android:src="@drawable/blinkoffline" android:background="@null" android:layout_gravity="center_horizontal" android:layout_below="@+id/btnswitch" android:layout_centerhorizontal="true" android:layout_margintop="40dp"/> <imagebutton android:layout_width="65dp" android:layout_height="70dp" android:id="@+id/alarmbutton" android:src="@drawable/alarmoffline" android:background="@null" android:layout_centerhorizontal="true" android:layout_below="@id/flashblinkbutton" android:layout_margintop="30dp"/> </relativelayout>
edit: automatically goes mdpi folder.
you can try set android:scaletype
for example :
<imagebutton android:id="@+id/flashblinkbutton" android:layout_width="75dp" android:layout_height="75dp" android:src="@drawable/blinkoffline" android:background="@null" android:layout_gravity="center_horizontal" android:layout_below="@+id/btnswitch" android:layout_centerhorizontal="true" android:layout_margintop="40dp" android:scaletype="fitxy" />
you can see different variations in docs http://developer.android.com/reference/android/widget/imageview.scaletype.html
Comments
Post a Comment