imageview - How to use different images for different screen sizes android? -
i have put pictures different sizes in mdpi, hdpi, xhdpi e.t.c. imagebuttons using image appear same size on each device.
so need add in manifest file?? or need in java code. last time did worked placing images in folders. don't remember did though.
i want display different size of images on different screens. have 5.7 inches phone, 5.0 inches phone , 7 inch tablet. app displays same size of image buttons in of them.
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/bg" tools:context="test.music.mainactivity"> <linearlayout android:id="@+id/linearlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="10dip"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> <textview android:id="@+id/nowplayingname_txtv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:maxlines="1" android:scrollbars="horizontal" android:text="ek mulaqat-www.songsfarm.ifo" android:textcolor="@color/title" android:textsize="20sp" android:textstyle="bold" /> <textview android:id="@+id/npduration_txtv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:maxlines="1" android:text="05:12" android:textcolor="@android:color/darker_gray" /> </linearlayout> <imagebutton android:id="@+id/settings_imgbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:backgroundtint="@color/bg" android:paddingleft="20dip" android:paddingright="20dip" app:srccompat="@mipmap/menu" /> </linearlayout> <listview android:id="@+id/songs_listv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_weight="1" android:longclickable="true" android:layout_below="@+id/linearlayout3" android:layout_above="@+id/song_seekbar" /> <linearlayout android:id="@+id/linearlayout2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:orientation="horizontal" android:paddingbottom="16dp"> <imagebutton android:id="@+id/prev_imgbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:backgroundtint="@color/bg" app:srccompat="@mipmap/prev" /> <space android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" /> <imagebutton android:id="@+id/pp_imgbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:backgroundtint="@color/bg" app:srccompat="@mipmap/play" /> <space android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" /> <imagebutton android:id="@+id/next_imgbtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:backgroundtint="@color/bg" app:srccompat="@mipmap/next" /> </linearlayout> <seekbar android:id="@+id/song_seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/linearlayout2" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:paddingbottom="16dip" android:paddingtop="16dip" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/linearlayout" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:id="@+id/linearlayout3"> <view android:layout_width="match_parent" android:layout_height="1dp" android:background="#d3d3d3" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_aligntop="@+id/song_seekbar" android:layout_alignparentleft="true" android:layout_alignparentstart="true"> <view android:layout_width="match_parent" android:layout_height="1dp" android:background="#d3d3d3" /> </linearlayout> </relativelayout>
you can use dimenify plugin. create standart set of dimens folders different screens, , convert dimens values, these screens. in way button have it's own size each screen:)
Comments
Post a Comment