Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将ViewPagerIndicator与片段底部对齐_Android_Android Layout_Android Fragments - Fatal编程技术网

Android 如何将ViewPagerIndicator与片段底部对齐

Android 如何将ViewPagerIndicator与片段底部对齐,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,我正在尝试使用Jake Wharton的ViewPagerIndicator,我想将指示器与屏幕底部对齐。然而,我遇到了这些问题 我的代码 activity_main.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app1="http://sche

我正在尝试使用Jake Wharton的ViewPagerIndicator,我想将指示器与屏幕底部对齐。然而,我遇到了这些问题

我的代码 activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:app1="http://schemas.android.com/apk/res/com.hidden.hidden"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.viewpagerindicator.LinePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:padding="10dip"
        app1:fillColor="@android:color/darker_gray" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/indicator" />

</RelativeLayout>
还有两个类似的,但不需要发布

有没有办法让指示器在屏幕底部有自己的布局,并让片段文本位于其上方?我在这里搜索了一下,但没有找到与ViewPagerIndicator相关的内容

提前谢谢

尝试在viewpager的底部对齐
    Try to align at the bottom of viewpager


  <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="50" >

                <android.support.v4.view.ViewPager
                    android:id="@+id/pager"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" >
                </android.support.v4.view.ViewPager>

                <com.viewpagerindicator.LinePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignBottom="@+id/pager"
        android:padding="10dip"
        app1:fillColor="@android:color/darker_gray" />
            </RelativeLayout>
尝试以下代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app1="http://schemas.android.com/apk/res/com.crm.dealerportal"
    xmlns:app="http://schemas.android.com/apk/res/com.crm.isf"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="5dp" >

    <TextView
        android:id="@+id/textViewDescription"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_weight="0"
        android:text="Text"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1" >
    </android.support.v4.view.ViewPager>

    <com.viewpagerindicator.LinePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:padding="5dip"
        app:gapWidth="20dip"
        app:lineWidth="40dip"
        app:selectedColor="@color/actionBarBG"
        app:strokeWidth="7dp"
        app:unselectedColor="@android:color/white" />

</LinearLayout>

指示器中尝试此设置属性
android:layout\u alignParentBottom=“true”
viewpager
android:layout\u Upper=“@+id/指示器”


当您在parent.com中使用相对布局时,它的属性为:

 android:layout_alignParentBottom="true"
只需将其添加到viewpager指示器小部件中,如:

 <com.viewpagerindicator.LinePageIndicator
    android:id="@+id/indicator"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:padding="10dip"
    app1:fillColor="@android:color/darker_gray" />


将在屏幕底部设置指示灯。

试试这种方法,希望这能帮助您解决问题

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app1="http://schemas.android.com/apk/res/com.hidden.hidden"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.viewpagerindicator.LinePageIndicator
        android:id="@+id/indicator"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:padding="10dp"
        app1:fillColor="@android:color/darker_gray" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>

尝试以下方法:

<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"
    >

    <android.support.v4.view.ViewPager 
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_alignParentTop="true"
        android:layout_above="@+id/indicator"
        />


    <com.viewpagerindicator.LinePageIndicator
            android:id="@+id/indicator"
            android:padding="10dp"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"       
            app1:fillColor="@android:color/darker_gray"

            />    

</RelativeLayout>


希望这有帮助

您可以使用LinearLayout。检查下面我的答案。我已成功地将指示器置于底部。为了更好,寻呼机应该对齐:android:layout\u alignParentTop=“true”
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app1="http://schemas.android.com/apk/res/com.hidden.hidden"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.viewpagerindicator.LinePageIndicator
        android:id="@+id/indicator"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:padding="10dp"
        app1:fillColor="@android:color/darker_gray" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>
<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"
    >

    <android.support.v4.view.ViewPager 
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_alignParentTop="true"
        android:layout_above="@+id/indicator"
        />


    <com.viewpagerindicator.LinePageIndicator
            android:id="@+id/indicator"
            android:padding="10dp"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"       
            app1:fillColor="@android:color/darker_gray"

            />    

</RelativeLayout>