Java 如何正确放置页面指示器。?
我已经创建了这个页面指示器,但我无法将其放置到正确的位置。我想它是在图像的中间或图像的底部,但是它在最靠近按钮的地方,我试过但是不能改变它的位置。 以下是活动的图像: 下面是我正在使用的活动的xml。您看到的页面指示器视图位于“查看寻呼机”下。任何形式的帮助都将不胜感激Java 如何正确放置页面指示器。?,java,android,xml,android-viewpager,Java,Android,Xml,Android Viewpager,我已经创建了这个页面指示器,但我无法将其放置到正确的位置。我想它是在图像的中间或图像的底部,但是它在最靠近按钮的地方,我试过但是不能改变它的位置。 以下是活动的图像: 下面是我正在使用的活动的xml。您看到的页面指示器视图位于“查看寻呼机”下。任何形式的帮助都将不胜感激 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xm
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:attrs="http://schemas.android.com/apk/res-auto"
android:background="#424242"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/appbar_header_height"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:expandedTitleMarginStart="@dimen/activity_margin_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewPager"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"/>
<com.rd.PageIndicatorView
android:id="@+id/pageIndicatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
app:piv_animationType="worm"
app:piv_dynamicCount="true"
app:piv_interactiveAnimation="true"
app:piv_selectedColor="@color/gray_50"
app:piv_unselectedColor="@color/gray_300"
app:piv_viewPager="@id/viewPager"
attrs:piv_padding="12dp"
attrs:piv_radius="8dp" />
<View
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_gravity="bottom"
android:background="@drawable/scrim"/>
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="@dimen/activity_margin_content"
android:paddingTop="@dimen/activity_margin_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listItem="@layout/item_dessert"/>
属性只是我为PageIndicatorView的大小定义的资源,它与它的原始位置无关
PageIndicatorView
可以定位为与任何其他视图100%相同的位置。请给我一个代码示例。这取决于这两个视图放置在哪个布局中。应用程序栏布局中的折叠工具栏布局您可以放置整个布局代码吗
myCustomPagerAdapter = new MyCustomPagerAdapter(AnimateToolbar.this, images);
viewPager.setAdapter(myCustomPagerAdapter);
final PageIndicatorView pageIndicatorView = findViewById(R.id.pageIndicatorView);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {/*empty*/}
@Override
public void onPageSelected(int position) {
pageIndicatorView.setSelection(position);
}
@Override
public void onPageScrollStateChanged(int state) {/*empty*/}
});