0

This is the layout when I use Linear Layout, if I use Relative layout, everything disappears我需要放置線性佈局超過v4.view.ViewPager

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context=".MainActivity" > 


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

<LinearLayout android:id="@+id/image_count" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:gravity="center" 
       android:background="#00000000"> 
    </LinearLayout> 

    <fragment 
    android:id="@+id/map1" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    class="com.google.android.gms.maps.MapFragment" /> 

</LinearLayout> 

它創建ViewPager片段和線性佈局(該線性佈局示出了具有使用點的選擇的當前頁面)和地圖的空間分段。我想要的是將當前位於XML佈局中間的線性佈局放置在ViewPager和NOT BELOW IT上。我該怎麼做。我在FrameLayout上嘗試過我的手,但它弄亂了一切。

回答

0

使用RelativeLayout設置在另一個

+0

關於使用RelativeLayout,一切都消失了。我附上了有關使用相對佈局的LinearLayout – user1377504

0

用的LinearLayout頂視圖,元素將行或列進行排序。改用相對佈局。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 


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

<LinearLayout android:id="@+id/image_count" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:gravity="center" 
       android:background="#00000000"> 
    </LinearLayout> 

    <fragment 
    android:id="@+id/map1" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    class="com.google.android.gms.maps.MapFragment" /> 

</RelativeLayout> 
+1

的屏幕截圖,所有元素在佈局上消失。 – user1377504