Reputation: 4401
I am new to programming for Androids. I am seeking for any information about programming for Androids. Now I am wondering how to change -for example- buttons size considering of what is screen size.
As an example I have:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_vertical"
android:baselineAligned="false"
android:layout_marginLeft="40px"
android:layout_marginRight="40px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
And now I need this layout for a phone:
android:layout_marginLeft="40px"
android:layout_marginRight="40px"
but if there would be a tablet then I need
android:layout_marginLeft="200px"
android:layout_marginRight="200px"
How could I achieve this?
Also if you have bookmarked good tutorials on how to handle orientation please share.
Thanks.
Upvotes: 2
Views: 131
Reputation: 1305
use dp instead of px for specifying margins and all.and try to use this in manifest file like this <supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
/>
Upvotes: 0
Reputation: 789
It is advisable not to use px, instead you should use dp i.e Density-independent Pixels. For orientation support you should declare separate layout xml.
Upvotes: 0
Reputation: 43504
I would suggest you to read up on "Supporting multiple screens" guide from android developers site and especially the section on "Declaring Tablet Layouts".
Upvotes: 1