Android 我的ViewPagerIndicator在哪里?
以下是我的布局:Android 我的ViewPagerIndicator在哪里?,android,android-viewpager,viewpagerindicator,Android,Android Viewpager,Viewpagerindicator,以下是我的布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.ViewP
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="@id/pager"
android:background="#808080"/>
</RelativeLayout>
当我运行应用程序时,该指示器不可见。我做错了什么?系统从XML文件的顶部到底部读取元素,因此在系统知道ViewPagerIndicator需要位于其下方之前,您的ViewPager已填充整个高度。交换订单,改用上面的
layout\u
:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#808080"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/titles" />
</RelativeLayout>
系统从XML文件的顶部到底部读取元素,以便在系统知道ViewPagerIndicator需要位于其下方之前,您的ViewPager将填充整个高度。交换订单,改用上面的
layout\u
:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#808080"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/titles" />
</RelativeLayout>
使用此
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pager"
android:background="#808080" />
</RelativeLayout>
使用此
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pager"
android:background="#808080" />
</RelativeLayout>
试试这个伴侣:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#808080"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/titles" />
</RelativeLayout>
试试这个伴侣:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/titles"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#808080"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/titles" />
</RelativeLayout>
03-03 11:44:12.119:E/AndroidRuntime(11417):java.lang.RuntimeException:无法启动活动组件信息{com.example.viewpager\u testproject/com.example.viewpager\u testproject.main活动}:java.lang.ClassCastException:com.viewpagerindicator.LinePageIndicator无法转换为android.support.v4.view.viewpager
:-(您确实也交换了android:id
s?像大多数奇怪的XML问题一样,尝试清理和重建您的项目。现在我的ViewPager
消失了xD到底是怎么回事?03-03 11:44:12.119:E/AndroidRuntime(11417):java.lang.RuntimeException:无法启动活动组件信息。){com.example.viewpager_testproject/com.example.viewpager_testproject.MainActivity}:java.lang.ClassCastException:com.viewpagerindicator.LinePageIndicator无法强制转换为android.support.v4.view.viewpager
:-(您确实也交换了android:id
s?像大多数奇怪的XML问题一样,尝试清理和重建您的项目。现在我的ViewPager
消失了xD到底是什么?是的,它确实工作了。您在这里做了什么更改?另外,我如何使指示器稍微大一点?是的,它确实工作了。您在这里做了什么更改?另外,如何使指示器稍微大一点?