Reputation: 61
Well i have activity.xml i which i have a background image and a button which also has a background image in it run well on normal screen but when i run it on xlarge or large screen the position of button changes
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/menu"
android:layout_margin="@dimen/my_view_margin"
>
<LinearLayout
android:layout_width="300px"
android:layout_height="200px"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="172dp"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="60px"
android:background="@drawable/bt"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
this is the code above and below are the images of different screen
cant add images cause doesnt have enough reputation
Upvotes: 4
Views: 44752
Reputation: 2192
Use weight for all layouts instead of giving constant values, Because weight is a type of % for screen.In manifest by default support screen view is true.
and if any times you think, It's not possible than add dimens values {folder contains dimens.xml}
Upvotes: 5
Reputation: 1141
Simple, use relative layout with the set margin code. Set the margins between each text view, button, etc and it will look the same on every phone.
android:layout_marginTop="10dp"
// change Top to Bottom, Left or Right for what you need.
Upvotes: 0
Reputation: 1659
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/my_view_margin"
android:background="@drawable/menu"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginTop="170dp"
android:layout_centerHorizontal="true"
android:background="@drawable/bt"
android:text="Button" />
</RelativeLayout>
Upvotes: 2
Reputation: 678
Use Relative layouts, draw 9 images. And for high quality apps you may create different different layout XMLS for all 4 screen sizes.http://developer.android.com/guide/practices/screens_support.html Use this link for more info.
Upvotes: 0