布局中的CirclePageIndicator没有改变?

时间:2014-03-15 23:25:50

标签: android eclipse viewpagerindicator

我的CirclePageIndicator没有显示圆圈,而是在我更改pageColor等时停滞不前。

我没有看到什么错误,并尝试了与我的问题相关的所有堆栈溢出答案。抱歉这个弱问题。

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

    <ImageView
        android:id="@+id/welcome_black_background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:background="@color/black"
        android:contentDescription="@string/description" />

    <ImageView
        android:id="@+id/welcome_background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/description"
        android:scaleType="centerCrop" />

    <android.support.v4.view.ViewPager
        android:id="@+id/welcome_view_pager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </android.support.v4.view.ViewPager>

    <ImageView
        android:id="@+id/welcome_path_logo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="@dimen/nux_welcome_logo_margin_top"
        android:contentDescription="@string/description"
        android:src="@drawable/nux_welcome_path" />

    <com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/welcome_dots"
        style="@style/CustomCirclePageIndicator"
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:layout_above="@+id/nux_welcome_button_container"
        android:layout_centerVertical="true"
        android:layout_marginBottom="@dimen/nux_view_welcome_dots_margin_bottom"
        android:background="@color/white" />


    <LinearLayout
        android:id="@+id/nux_welcome_button_container"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/welcome_branding_bar"
        android:layout_marginLeft="20.0dip"
        android:layout_marginRight="20.0dip"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/nux_welcome_register_button"
            style="@style/nux_welcome_button"
            android:layout_width="0.0dip"
            android:layout_height="wrap_content"
            android:layout_marginRight="5.0dip"
            android:layout_weight="1.0"
            android:text="@string/welcome_register"
            android:textColor="@color/register_button_red" />

        <Button
            android:id="@+id/nux_welcome_login_button"
            style="@style/nux_welcome_button"
            android:layout_width="0.0dip"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5.0dip"
            android:layout_weight="1.0"
            android:text="@string/welcome_login" />
    </LinearLayout>

    <FrameLayout
        android:id="@+id/welcome_branding_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@drawable/welcome_branding_gradient" >

        <TextView
            android:id="@+id/welcome_creator_field_recognition"
            style="@style/shop_premium_popover_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:drawablePadding="6.0dip"
            android:drawableRight="@drawable/pare_ic_actionbar"
            android:gravity="bottom"
            android:text="@string/created_by"
            android:textColor="#ffffffff" />
    </FrameLayout>

</RelativeLayout>

这是我的styles.xml

<style name="StyledIndicators" parent="@android:style/Theme.Light">
    <item name="vpiCirclePageIndicatorStyle">@style/CustomCirclePageIndicator</item>
</style>

<style name="CustomCirclePageIndicator">
    <item name="fillColor">#FF000000</item>
    <item name="strokeColor">#FF000000</item>
    <item name="pageColor">#FF000000</item>
    <item name="strokeWidth">2dp</item>
    <item name="radius">10dp</item>
    <item name="centered">true</item>
</style>

2 个答案:

答案 0 :(得分:0)

你忘记了

myIndicator.setViewPager(myPager); 

答案 1 :(得分:0)

无法添加myIndicator.onPageScrolled(myViewPager.getCurrentItem(), 0, 0);也可能导致此问题。

例如:myViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { myIndicator.onPageScrolled(myViewPager.getCurrentItem(), 0, 0); } });