2013-10-10 65 views
1

我是android新手。我正在使用谷歌地圖製作應用程序。 在佈局文件3部分即頂層,中間層,底層。 頂層圖層標題,底層圖層選擇按鈕。 在中間層片段和編輯文本。當我點擊編輯框然後片段上升。當片段回到位置時,頂層將不可見。我不知道會發生什麼。地圖佈局問題

<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" 
android:background="@drawable/bg" 
tools:context=".MainActivity" > 

<RelativeLayout 
    android:id="@+id/topLay" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/jam_alert_topbar" 
    > 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/midLay" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_above="@+id/botLay" 
    android:layout_below="@+id/topLay" 
    android:layout_margin="10dp" > 

    <fragment 
     android:id="@+id/mapView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/descr" 
     android:layout_below="@+id/topLay" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

    <EditText 
     android:id="@+id/descr" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginTop="5dp" 
     android:background="@color/white" 
     android:gravity="top|left" 
     android:hint="Description" 
     android:maxLines="4" 
     android:minLines="4" > 
    </EditText> 
</RelativeLayout> 

<LinearLayout 
    android:id="@+id/botLay" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:gravity="center" > 

    <Button 
     android:id="@+id/btReport" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/jam_tab_n" 
     android:onClick="btReport" /> 

    <Button 
     android:id="@+id/btMap" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/map_tab_h" 
     android:onClick="btMap" /> 

    <Button 
     android:id="@+id/btHome" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/report_tab_n" 
     android:onClick="btHome" /> 

    <Button 
     android:id="@+id/btSetting" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/settings_tab_n" 
     android:onClick="btSetting" /> 
</LinearLayout> 

回答

1

試試這個,你是否嘗試過這個?在特定活動中添加windowSoftInputMode屬性

android:windowSoftInputMode="adjustPan" 

在您的xml中。添加機器人:layout_alinParentTop =「真」在你最RelativeLayout的

<RelativeLayout 
android:id="@+id/topLay" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/jam_alert_topbar" 
android:layout_alinParentTop="true" 
> 
</RelativeLayout> 
+1

我想這機器人:windowSoftInputMode =「ststeHidden/adjustresize」 它的工作原理,但它會將所有3層的頂部,我想,以上athe 2層都漲了 –

+0

同樣的問題對不起:( –

+1

pleae對我來說真的很好笑@Murli Ganesan –

0
// try this 
<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" 
       android:background="@drawable/bg" 
       tools:context=".MainActivity" > 

    <LinearLayout 
      android:id="@+id/topLay" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:background="@drawable/jam_alert_topbar"> 
    </LinearLayout> 

    <LinearLayout 
      android:id="@+id/midLay" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:layout_margin="10dp" > 

     <fragment 
       android:id="@+id/mapView" 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       class="com.google.android.gms.maps.SupportMapFragment" /> 

     <EditText 
       android:id="@+id/descr" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="5dp" 
       android:background="@color/white" 
       android:gravity="top|left" 
       android:hint="Description" 
       android:maxLines="4" 
       android:minLines="4" > 
     </EditText> 
    </LinearLayout> 

    <LinearLayout 
      android:id="@+id/botLay" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" > 

     <Button 
       android:id="@+id/btReport" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/jam_tab_n" 
       android:onClick="btReport" /> 

     <Button 
       android:id="@+id/btMap" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/map_tab_h" 
       android:onClick="btMap" /> 

     <Button 
       android:id="@+id/btHome" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/report_tab_n" 
       android:onClick="btHome" /> 

     <Button 
       android:id="@+id/btSetting" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/settings_tab_n" 
       android:onClick="btSetting" /> 
    </LinearLayout> 
</LinearLayout> 
+0

先生我想讓它成爲多屏不僅適用於單屏 –