Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please verify my layout: bottom button keeps coming up over keyboard

Tags:

android

layout

I have a layout which does almost what I want. There's just one bug regarding the button at the bottom. I should stay at the bottom at all times. But whenever I bring up the soft-keyboard the button will be displayed above the keyboard. This is not what I want but it should become covered by the keyboard.

Moreover, I'd be happy if you could comment on how the layout's built.

Thanks, steff

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<LinearLayout android:id="@+id/l_layout_tags"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:text="TAGS:"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <AutoCompleteTextView android:id="@+id/actv_tags"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:imeOptions="actionDone" />
    <ImageButton android:id="@+id/btn_add_tag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_input_add"
        android:onClick="addTag"/>
</LinearLayout>

<ScrollView android:id="@+id/sv_scroll_contents"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/l_layout_tags"
    android:scrollbarFadeDuration="2000" >
    <TableLayout android:id="@+id/t_layout_contents"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="1"
        android:paddingRight="5dip">
        <TableRow android:id="@+id/tr_template">
            <ImageView android:id="@+id/iv_blank"
                android:src="@android:color/transparent" />
            <EditText android:id="@+id/et_content1"
                android:gravity="top"
                android:maxWidth="200dp"
                android:imeOptions="actionDone" />
        </TableRow>
    </TableLayout>
</ScrollView>

<LinearLayout android:id="@+id/l_layout_media_btns"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_centerHorizontal="true"
    android:layout_below="@id/sv_scroll_contents" >
    <ImageButton android:id="@+id/btn_camera"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_camera"
        android:onClick="takePicture" />
    <ImageButton android:id="@+id/btn_video"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_camera" />
    <ImageButton android:id="@+id/btn_audio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_btn_speak_now" />
    <ImageButton android:id="@+id/btn_sketch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_edit" />
</LinearLayout> 

<ImageButton android:id="@+id/btn_save_note"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:src="@android:drawable/ic_menu_upload" />

</RelativeLayout>
like image 444
stfn Avatar asked Mar 12 '10 14:03

stfn


People also ask

How do I keep the button on the bottom of my screen Android?

Make the Parent of the LinearLayout containing the button as relative and set the property of linear layout containing two buttons as android:layout_alignParentBottom="true". You can also set the gravity of the Linear Layout to Bottom. Save this answer.


2 Answers

Add android:windowSoftInputMode="adjustPan" to your activity tag in the AndroidManifest.xml.

This way, the software keyboard won't resize your layout and your button will stay under it. Take a look here to get a better idea about different soft keyboard modes.

like image 115
Dimitar Dimitrov Avatar answered Nov 16 '22 01:11

Dimitar Dimitrov


I had a similar problem. In which I have to show one button at bottom of screen always. I solved the problem of button is coming up of the keyboard in the following way:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" 
   android:background="@color/white"
   android:gravity="center_horizontal"
   >
       <ScrollView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:layout_gravity="center"
        android:id="@+id/ff"
        >
                 .......
       </ScrollView>

       <LinearLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1">
            <TextView
            android:id="@+id/txtSigninProblem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"         
            android:layout_below="@+id/ff"
            android:layout_gravity="bottom|center_horizontal"           
            android:text="Problem Signing in?"
            />
        </LinearLayout>
 </LinearLayout>
like image 38
Jomia Avatar answered Nov 16 '22 02:11

Jomia