Skip to content Skip to sidebar Skip to footer

Nested Viewflipper Layout

I am trying to create a custom tabbed layout with a viewflipper. Therefore, I need two buttons side-by-side at the top of the screen. I have this. However, I am trying to get the v

Solution 1:

Your LinearLayout that contains the buttons has a layout_height="fill_parent". You need to set that to wrap_content and also specify the orientation="vertical" in the parent LinearLayout. You'll also need to specify a layout_weight for the view that you want to stretch to fill.

Because linearLayout01LinearLayout has its layout_height set to fill_parent, android is going to make it take up the reset of the screen. The content below that will not be visible at all because it is off the screen.

<LinearLayoutandroid:id="@+id/linearLayout01"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"xmlns:android="http://schemas.android.com/apk/res/android"><LinearLayoutandroid:id="@+id/linearLayout02"android:layout_width="fill_parent"android:layout_height="wrap_content"><Buttonandroid:id="@+id/button01"android:layout_height="wrap_content"android:text="Button 1"android:layout_width="0dip"android:layout_weight="1"></Button><Buttonandroid:id="@+id/button02"android:layout_height="wrap_content"android:text="Button 2"android:layout_width="0dip"android:layout_weight="1"></Button></LinearLayout><RelativeLayoutandroid:id="@+id/relativeLayout01"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"><ViewFlipperandroid:id="@+id/flipper01"android:layout_width="fill_parent"android:layout_height="fill_parent"
        ><TextViewandroid:id="@+id/textview01"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Text"
        /><TextViewandroid:id="@+id/textview02"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Text2"
        /></ViewFlipper></RelativeLayout></LinearLayout>

Solution 2:

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/linearLayout01"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><Buttonandroid:id="@+id/button01"android:layout_height="wrap_content"android:text="Button 1"android:layout_width="0dip"android:layout_weight="1" /><Buttonandroid:id="@+id/button02"android:layout_height="wrap_content"android:text="Button 2"android:layout_width="0dip"android:layout_weight="1" /><ViewFlipperandroid:id="@+id/flipper01"android:layout_width="fill_parent"android:layout_height="fill_parent" ><RelativeLayoutandroid:id="@+id/relativeLayout01"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"><!-- Screen 1: Wherever view you want to display on the first screen --></RelativeLayout><RelativeLayoutandroid:id="@+id/relativeLayout02"android:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"><!-- Screen 2: Wherever view you want to display on the second screen --></RelativeLayout></ViewFlipper></LinearLayout>

Generally, you have to ViewFlipper that contains the two or more layout that you want to display when, for example, click a buttom and whatever you want to see in all of screen, write outside of ViewPager tag.

Post a Comment for "Nested Viewflipper Layout"