How do i proceed with designing an android activity with two fragments such their layout are as follows in landscape and portrait mode respectively. I tried putting two fragments inside a frame layout set as vertical but it didnt work. I tried this with linear layout but didnt get expected result
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="vertical" >
<fragment
android:id="@+id/titles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
class="com.examples.fragments.Fragment1" />
<fragment
android:id="@+id/details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
class="com.examples.fragments.Fragment2" /></LinearLayout>
A FrameLayout
doesn't have an orientation. You should use a LinearLayout
. It supports the android:orientation
attribute.
And by the looks of your disign you might need to use android:layout_weight
with android:layout_height="0dp"
(or android:layout_width="0dp"
) as well.
You should use a LinearLayout with orientation attribute. You can design two different layout. Check this link for this second approach:
http://developer.android.com/training/basics/supporting-devices/screens.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.