Reputation: 806
I am new in android. I am making an app using google map. In the layout file 3 part i.e Top Layer,Mid Layer,Bottom Layer. In Top layer a header, in bottom Layer TAB button. In Mid Layer Fragment and Edit text. When I click on edit box then fragment gone up. when fragment comes back at position then hte top layer is going to invisible. I don't know what happens.
<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>
Upvotes: 1
Views: 99
Reputation: 24848
// 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>
Upvotes: 0
Reputation: 2955
Try this, Have you tried this one?. Add windowSoftInputMode attribute in particular activity
android:windowSoftInputMode="adjustPan"
In your xml. add android:layout_alinParentTop="true" in your top 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>
Upvotes: 1