Button and background size/resolution in android

3.6k Views Asked by At

I went through the Developer documents,partly understood the LDPI,HDPI,MDPI,XHDPI analogy, searched everywhere on the net but could not find specific answers.

I have two phones, one has a small screen and one is a tablet. I want the buttons on my small screen phone look small and the same buttons on the big screen look more big and occupy more space. How do I achieve this? Any tutorials?

(I place drawables in specific drawable folders and huge buttons are displayed on my small screen) Confused!

I also created different layouts specifying the DPI, what I dont understand is that if the DPI of my small screen and big screen is same, the layout will be distorted on the bigger or conversly the smaller one!

3

There are 3 best solutions below

7
On

read this http://developer.android.com/guide/practices/screens_support.html and check the size qualifiers section

eg, from the same link

res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)
0
On

apparently you have a lot to learn on the resources as overall, but specifically for buttons you might want to look into using a shape drawables (for simple backgrounds) or 9 patch for more complex ones as those solutions stretch much more efficiently than standard PNG backgrounds.

http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

http://developer.android.com/tools/help/draw9patch.html

google around you'll find good resources on the and even some tools to automate the creation of those resources.

0
On

Why not to go for nine-patch images ? Here is the Android Asset Studio.

It helps you to create nine-patch images instantly . Here it is some useful information regarding nine patch. Just go through it .... Hope it helps...