2015-10-13 100 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