开发者

Android View Flipper Custom Drawing

I have a few doubts about view flipper

I am using viewflipper to go to another view using scroll_left animation.

i have kept 2 linearlayouts inside the ViewFlipper

now i want 4 views....

like 1st view c开发者_如何转开发ontains 3 btns.

1st btn click -> 2nd view scrolls in -> back pressed 1st view scrolls back 2nd btn click -> 3rd view scrolls in -> back pressed 1st view scrolls back 3rd btn click -> 4th view scrolls in -> back pressed 1st view scrolls back

so, how am i going to arrange 4 linearlayouts to work in flipNext ....

now ideally 2, 3, 4 views are in only second level of navigation. I want to draw a line, point or rectangle when 2, 3, 4 views come up, but they all are different shapes. So what would be the method to draw that ?


You can do it the following way:

<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/header">
<TextView
android:id="@+id/header_text"
android:gravity="center"
android:textSize="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:layout_width="fill_parent"
    android:paddingBottom="5px">
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/flipper"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <include android:id="@+id/chatView"  layout="@layout/chat_view" />
    <include android:id="@+id/userView"  layout="@layout/user_view" />
    <include android:id="@+id/gameView" layout="@layout/game_view"/>
    <include android:id="@+id/allGamesView" layout="@layout/all_game_view" />
</ViewFlipper>

As you can see, i defined a TextView which is displayed every time. The ViewFlipper is below this header TextView. So you only flip this part of the whole view. To flip from view 1 to 2, you just call

flipper.showNext();

Do flip from 1 to 3, you just call:

flipper.showNext();
flipper.showNext();

And to flip from 4 to 2, you call:

flipper.showPrevious();
flipper.showPrevious();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜