I am creating an android application that should be supported for both phones and tablets. I found a way to create multiple layout files for each size, but I don't want to do it. Is there any way to do it through programming or some other way.
Asked
Active
Viewed 62 times
-4
-
1Which way do you try to do this? – Sergei Bubenshchikov Jan 17 '17 at 06:19
-
yes you will achive this by using proper .xml design. – Sagar Aghara Jan 17 '17 at 06:19
-
use dimen files with different size density and write suitable dimensions for your xml for different resolution. http://stackoverflow.com/questions/9877946/text-size-and-different-android-screen-sizes check this link with the accepted answer. – Ankush Bist Jan 17 '17 at 06:21
-
Thanks for your help. I am new to android and unable to do it. Sagar Aghara : Can you elaborate your answer please.? – Saloni Jan 17 '17 at 06:24
-
Ankush Bisht : I already mentioned, Is there any other way I can do it without creating individual files for different dimensions. – Saloni Jan 17 '17 at 06:27
-
@Rider..i think you have to go in Developer site for Android.you can collect more Knowledge from there...yes also check below answer. – Sagar Aghara Jan 17 '17 at 06:31
2 Answers
0
Don't specify the width and height to certain dp values. Instead give it as match_parent
or wrap_content
.
Also, try to include the following in manifest file.
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />

Meena Dev
- 82
- 1
- 9
-
Thank you Meena. I have one more doubt. My layout is not displayed properly in tablet as it gets displayed in phone. What should I do to get the proper layout? – Saloni Jan 17 '17 at 06:41
-
And also I want my app to work only in portrait, not landscape. How can I do that.? – Saloni Jan 17 '17 at 07:07
-
-
Hey Meena, As asked by you, I added my xml file. Can you please explain me what edits I should make to get proper layout in phone and tablets. – Saloni Jan 17 '17 at 09:15
-
can you attach the screenshots of the design page taken from phone and tablet. – Meena Dev Jan 17 '17 at 10:09
-
-
0
Try to put height and width match parent and give weight ti every content then it will render in every screen.

prem nath
- 75
- 1
- 12