3

In following code the viewflipper is not taking the whole screen it just wraps around the textview. why is this happening ?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView  
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#0000ff" >

        <ViewFlipper android:id="@+id/ViewFlipper01"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#aa0000"
            android:layout_gravity="center">  

            <TextView
                android:layout_width="match_parent"
                android:layout_height="50dp"></TextView>

        </ViewFlipper>
    </ScrollView>
</LinearLayout>
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
John Watson
  • 869
  • 3
  • 16
  • 32

3 Answers3

5

In scrollView use

android:fillViewport="true"

Mohsin Naeem
  • 12,542
  • 3
  • 39
  • 53
0
<ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0000ff" >

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ViewFlipper android:id="@+id/ViewFlipper01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#aa0000"
        android:layout_gravity="center">  

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp">
        </TextView>

</ViewFlipper>
</LinearLayout>
</ScrollView>

this will work.

Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
-1

Why do you want to increase View Flippers height? View Flipper depends upon the content or views you add inside it..So the height and width of view flipper will be always equal to the largest height/width your provide to the views. In your case its text view so if you increase the height of the current view or add another textView with height greater than the current one view flipper will be increased.

Rekha
  • 901
  • 1
  • 11
  • 20
  • because viewflipper is occupying only half of the screen,which is not looking good, hence, i want its content to spread and take up more space , for that viewflipper has to expand – John Watson Aug 20 '12 at 16:15