2015-10-13 101 views
1

我想添加查看页面指标圈到屏幕上,我有代码工作,当我滑动图像将改变,以指示我在哪个网页上。框架布局内定位

虽然我不能将布局放在我想要的位置,但它确实在文档中说框架布局应该只包含一个孩子,但我已经看到很多这种情况看起来不是这样的例子。

是否无法在框架布局中放置相对布局?

我想要在视图传呼机上出现点状条,但在底部,就像带点的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> 

回答

4

您使用了错误的语法,为FrameLayout里你应该使用layout_gravity = “底部| CENTER_HORIZONTAL”,而不是机器人:layout_alignParentBottom = “真”

试试这个;

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

+0

有了小幅度的我现在正是我一直在努力实现,谢谢。 – berimbolo