2

I am working on a app in which there are some textfiels and button when I am running it on different screen size devices it is showing unexpected result as shown in the below image!

[Image 1] http://oi45.tinypic.com/25yvon4.jpg [Image 2] http://oi45.tinypic.com/xmlqns.jpg

Here in first image some space is left vacant at the bottom due to large screen size and in second image the last row of buttons are hidden due to small screen size.Also for buttons I am using Table Layout.

Is there any way to solve this problem.

3 Answers 3

4

That's a broad topic that needs spatial understanding first. Here's a good place to start - http://developer.android.com/guide/practices/screens_support.html

Long story short, always use point units (dps), try to avoid to hardcoded pixels within your code, position items in a relative way (ie.: in relation to other object - RelativeLayout, LinearLayout, etc) and make sure to take advantage of the power of "values-..." folders. Example

values-xhdpi (XH)

values-hdpi (H)

values-mdpi (M)

values-land (Landscape)

values-sw600dp (smallest width at least 600dp)

....

Sign up to request clarification or add additional context in comments.

Comments

2

Use layout, layout-large and layout-xlarge resource folders to customize your layout files if you care about various screen sizes. Test these layouts on phones, 7" and 10" tablets to cover all of your bases.

For small phones of less than 4" screens (qvga) as well as older devices (wvga), make custom layout files (in the layout folder) and refer to them dynamically in your java code when you detect these kinds of devices. Again, test on these older & smaller phones as much as possible. Borrow some phones from the Sony Device Loaner Program in order to get real-world testing done.

Lastly, use ScrollView to embed your layouts if you want vertical scrolling on smaller screens. Don't go crazy trying to fit everything on a smaller screen. Sometimes scrolling is a natural solution that your users will understand.

Comments

0

You must have to make screen for all devices if you want to solve your problem.Read below document for different screen:-

http://developer.android.com/guide/practices/screens_support.html

or

You can use weight or layout weight to prevent this problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.