定位内部框架布局

ber*_*olo 5 layout android

我正在尝试将视图页面指示符圈添加到屏幕上,并且我有代码工作,因为我滑动图像将更改以指示我在哪个页面.

我似乎无法将布局定位在我想要的位置,它确实在文档中说框架布局应该只包含一个孩子,但我已经看到很多例子,这似乎并非如此.

是否无法在框架布局中定位相对布局?

我希望条带点出现在视图寻呼机上但在底部,就像带有点的ios内容视图一样.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dark_blue">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_marginTop="3dp"
    android:layout_marginLeft="3dp"
    android:layout_marginBottom="3dp"
    android:layout_marginRight="3dp"
    android:id="@+id/home_addr_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1">

</android.support.v4.view.ViewPager>
<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/dots"
        />
</RelativeLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

vgu*_*zzi 8

您使用了错误的语法,对于FrameLayout,您应该使用layout_gravity ="bottom | center_horizo​​ntal"而不是android:layout_alignParentBottom ="true"

试试这个;

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/home_addr_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="3dp"
    android:layout_marginLeft="3dp"
    android:layout_marginRight="3dp"
    android:layout_marginTop="3dp"
    android:layout_weight="1">

</android.support.v4.view.ViewPager>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|center_horizontal">

    <LinearLayout
        android:id="@+id/dots"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="bottom|center_horizontal"
        android:orientation="horizontal"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)