Nested viewFlipper Layout

前端 未结 2 783
-上瘾入骨i
-上瘾入骨i 2021-01-22 01:38

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 th

相关标签:
2条回答
  • 2021-01-22 02:24

    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 linearLayout01 LinearLayout 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.

    <LinearLayout
     android: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">
    
    <LinearLayout
     android:id="@+id/linearLayout02" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content">
        <Button android:id="@+id/button01" android:layout_height="wrap_content" android:text="Button 1" android:layout_width="0dip" android:layout_weight="1"></Button>
        <Button android:id="@+id/button02" android:layout_height="wrap_content" android:text="Button 2" android:layout_width="0dip" android:layout_weight="1"></Button>
    </LinearLayout>
    
    <RelativeLayout
     android:id="@+id/relativeLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp"
     android:layout_weight="1">
        <ViewFlipper
            android:id="@+id/flipper01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
        <TextView
            android:id="@+id/textview01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text"
            />  
            <TextView
            android:id="@+id/textview02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text2"
            />  
    
        </ViewFlipper>
        </RelativeLayout>
    </LinearLayout>
    
    0 讨论(0)
  • 2021-01-22 02:36
        <LinearLayout xmlns: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" >   
    
                <Button android:id="@+id/button01" 
        android:layout_height="wrap_content" 
        android:text="Button 1" 
        android:layout_width="0dip" 
        android:layout_weight="1" />
    
        <Button android:id="@+id/button02" 
        android:layout_height="wrap_content" 
        android:text="Button 2" 
        android:layout_width="0dip" 
        android:layout_weight="1" />
    
        <ViewFlipper
        android:id="@+id/flipper01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    
    
        <RelativeLayout
         android: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>
        <RelativeLayout
         android: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.

    0 讨论(0)
提交回复
热议问题