Android的CirclePageIndicator不工作 [英] Android CirclePageIndicator not working

查看:101
本文介绍了Android的CirclePageIndicator不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是能与circlepageindicator加载页面。这是XML

Im not able to load the page with circlepageindicator. This is the xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="@drawable/bg2" android:layout_width="match_parent"
    android:layout_height="match_parent" />
<LinearLayout android:layout_width="220dp"
    android:orientation="vertical" android:layout_gravity="center_horizontal"
    android:layout_height="32dp" android:layout_marginTop="32dp">
    <android.support.v4.view.ViewPager
        android:layout_width="match_parent" android:layout_height="match_parent"
        android:id="@+id/myfivepanelpager" />   

    <com.viewpagerindicator.CirclePageIndicator
    android:id="@+id/indicator"
    android:padding="10dip"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    />

</LinearLayout>

 java的文件

java file

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    MyPagerAdapter adapter=new MyPagerAdapter();
    ViewPager myPager=(ViewPager)findViewById(R.id.myfivepanelpager);
    myPager.setAdapter(adapter);
    myPager.setCurrentItem(2);

    CirclePageIndicator titleIndicator = (CirclePageIndicator)findViewById(R.id.indicator);
    titleIndicator.setViewPager(myPager);
}

杰克沃顿项目已被添加到库中。同时建立,但不能加载页面它没有给出任何错误。什么错?

jake wharton project has been added to the library. It doesnt give any error while building, but not loading the page. whats wrong?

推荐答案

ViewPager 设置为 match_parent 这将prevent在容器中的任何其它视图的显示。在 ViewPager 高度设置为 0dp 的android:layout_weight =1

Your ViewPager is set to match_parent which will prevent any other view in the container from showing. Set the ViewPager height to 0dp with android:layout_weight="1".

容器也是硬coded到 32dp 这是极其微小的,有可能不会同时按住寻呼机和指标舒适。

The container is also hard-coded to 32dp which is extremely tiny and likely will not hold both the pager and indicator comfortably.

这篇关于Android的CirclePageIndicator不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆