Android: screen orientation with FrameLayout & relativeLayout [duplicate]
I have an android application that consists of main layout of FrameLayout which has two views set in RelativeLayout. (see layout XML files below). The problem is with second view (view2) screen orientation (the view turn to black and app is frozen).
I have tried with no success to use the option android:orientation="horizontal" in the layout-land resource.
Please advise.
Thank you. Oakist
main.xml开发者_StackOverflow中文版
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="@+id/notelist" layout="@layout/view1" />
<include android:id="@+id/notelist" layout="@layout/view2" />
</FrameLayout>
view1.xml
<RelativeLayout android:id="@+id/Layout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:id="@+id/image01"
android:layout_height="wrap_content"
>
</ImageView>
</RelativeLayout>
view2.xml
<RelativeLayout android:id="@+id/Layout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:id="@+id/image02"
android:layout_height="wrap_content"
>
</ImageView>
</RelativeLayout>
Android documentation says
FrameLayout FrameLayout is the simplest type of layout object. It's basically a blank space on your screen that you can later fill with a single object — for example, a picture that you'll swap in and out. All child elements of the FrameLayout are pinned to the top left corner of the screen; you cannot specify a different location for a child view. Subsequent child views will simply be drawn over previous ones, partially or totally obscuring them (unless the newer object is transparent).
You have two childs, one over the other. I assume that this what you want, do you? Have you tried to put the imageviews directly into the frame layout? What is the effect then?
精彩评论