Reputation: 187
I have nearly finished my app but still have to make sure landscape orientations is ok, is there any xml code that I can put in layout that will cover both portrait and landscape?
Many thx
Upvotes: 0
Views: 231
Reputation: 1598
use RelativeLayout in your xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/boxbig" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Bottom and Right"
/>
</RelativeLayout>
Upvotes: 1
Reputation: 5322
Your layout will work in both orientations. You can specify a layout for landscape orientation by adding an xml with the same name in a folder named layout-landscape
as per this document. Note that you should handle make sure your App works correct when orientation is changed as Android may recreate your view if you do not handle the orientation change.
Upvotes: 1