1

我想实现这样的东西:http ://android-developers.blogspot.in/2011/08/horizo​​ntal-view-swiping-with-viewpager.html 。
我的主视图是一个 Viewflipper,在卡片的两侧有两个视图。如何在 viewflipper 布局上方实现一个 viewpager?我现在的布局是这样的:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout android:id="@id/FlashCardFront" android:background="#3500ffff style="@style/Fill"
xmlns:android="http://schemas.android.com/apk/res/android">
<ViewFlipper android:id="@+id/flipper" style="@style/Fill" android:layout_margin="8.0dip">       
<LinearLayout android:id="@+id/front" android:orientation="vertical" android:background="#ffffffff"  style="@style/Fill">
    <LinearLayout style="@style/FillWrap.LL.FlashCard_Header">

       <ImageButton 
 android:id="@+id/back"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:onClick="true"
 android:src="@drawable/left_arrow"
android:background="#00000000"
 />   

        <TextView android:id="@id/TV_CardNo" android:text="0000" android:layout_weight="1.0" style="@style/Wrap.Text_RightTop" />

        <ImageButton
            android:id="@+id/next"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.14"
            android:background="#00000000"
            android:onClick="true"
            android:src="@drawable/right_arrow" />

        </LinearLayout>

        <LinearLayout android:id="@id/LL_Card" style="@style/FillWrap.LL.FlashCard_Body">
        <TextView android:id="@id/TV_Word" android:text="Word" style="@style/FillWrap.Text_FlashCard_Word" />
        </LinearLayout>

        <LinearLayout style="@style/FillWrap.LL.FlashCard_Footer">
        <RatingBar android:id="@id/RB_Stars_Front" android:progressDrawable="@drawable/ratings_bar" android:numStars="1" android:stepSize="1.0" style="@style/Wrap" />
    </LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="vertical" android:background="#ffffffff"  style="@style/Fill">

    <LinearLayout android:id="@id/RearHeader" style="@style/FillWrap.LL.FlashCard_Header">
          <ImageButton 
 android:id="@+id/rear_back"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:onClick="true"
 android:src="@drawable/left_arrow"
android:background="#00000000"
 />   
        <TextView android:id="@id/TV_CardNo" android:text="0000" android:layout_weight="1.0" style="@style/Wrap.Text_RightTop" />
        <ImageButton
            android:id="@+id/rear_next"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.14"
            android:background="#00000000"
            android:onClick="true"
            android:src="@drawable/right_arrow" />       
    </LinearLayout>
    <LinearLayout android:id="@id/LL_Card1" style="@style/FillWrap.LL.FlashCard_Body">
    <ImageView android:id="@+id/image"  android:layout_width="fill_parent" android:layout_height="fill_parent"></ImageView>        </LinearLayout>
    <LinearLayout style="@style/FillWrap.LL.FlashCard_Footer">
                <TextView android:id="@id/TV_Meaning" android:text="Meaning" style="@style/FillWrap.Text_FlashCard_Meaning" />
    </LinearLayout>
</LinearLayout>
</ViewFlipper>

4

2 回答 2

0

页面上的样式是使用名为 viewpagerindicator 的库完成的……由 Jake wharton 完成……检查它是如何工作的

于 2012-05-08T12:54:56.837 回答
0

Simply create a Linearlayout with the horizontal orientation, then add dot image to the layout. And set the code for changing the position of the selected dot inside of the ViewPager pageChangedListner.

Thank you.

于 2018-04-11T05:06:31.903 回答