How To Keep Android Layout Consistent Across Various Devices?
Solution 1:
Rethink your design and provide a delightful experience for your users.
You need to focus on some areas of variability in Android devices and how those variations affect the development and design of Android applications.
- Layout Position
- Size, Padding and Margins
- Common Layouts
- Resource Qualifiers
- Split Views
Conclusion:
if Your Are Concerning with one screen layout than use linear layout with weights. OFFICIAL Example:
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingLeft="16dp"android:paddingRight="16dp"android:orientation="vertical" ><EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:hint="@string/to" /><EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:hint="@string/subject" /><EditTextandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="top"android:hint="@string/message" /><Buttonandroid:layout_width="100dp"android:layout_height="wrap_content"android:layout_gravity="right"android:text="@string/send" />
else use scroll-able layouts like listview card view with realitivelayout for each row because it is more efficiently.
P.S. You have a lot of unnecessary atributes set in xml.. I just did this in a few sec to help you. You should read how RelativeLayout and LinearLayout work. For More knowledge read official documents
Solution 2:
I recommend you that read this pages: http://www.google.com/design/spec/layout/metrics-keylines.html
There you have a design guidelines to create apps for desktop, tablet and phone.
About code, you only need to create layouts for each device (usually tablet and phone, or add too TV and wear).
Solution 3:
You can use PercentRelativeLayout in which you can set positions, sizes and margins using percentages. Check the link below.
http://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html
Post a Comment for "How To Keep Android Layout Consistent Across Various Devices?"