Answer the question
In order to leave comments, you need to log in
Raise the buttons above the keyboard?
In my application, there are two activities where there is a text input field, and below it there are three buttons. So I have a problem - when you click on textedit, the keyboard pops up and closes the buttons, but I need the buttons to be above the keyboard. Please help with solving the problem?
PS I wanted to insert screenshots (I'm writing from my phone), but this is not possible here, so the link to the application. Windows in which the problem is "Learn words" and "Repeat words" https://play.google.com/store/apps/details?id=fomi...
Here is the xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/fragment_learn_words"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:orientation="horizontal">
<******rest.DynamicImageView
android:id="@+id/ivWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="0.5dp"
android:layout_weight="1"
android:gravity="center"
android:scaleType="centerCrop"
android:src="@drawable/empty_picture" />
<TextView
android:id="@+id/tvWord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="0.5dp"
android:layout_weight="0.5"
android:background="@color/color_inter_color_background"
android:gravity="center"
android:text="@string/emptyWord"
android:textColor="@color/color_inter_color_font"
android:textSize="35sp"
android:textStyle="bold" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_weight="0.4">
<EditText
android:id="@+id/etEnterWord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:background="@color/colorGrey"
android:gravity="center_horizontal"
android:hint="@string/etHintEnterWord"
android:inputType="textNoSuggestions"
android:maxLength="15"
android:minLines="1"
android:textSize="35sp"
android:textStyle="bold" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginTop="1dp"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:layout_margin="2dp"
android:layout_marginTop="1dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/btnHelp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="0.5dp"
android:layout_weight="1"
android:background="@color/color_inter_color_background_button"
android:gravity="center"
android:text="@string/btnHelp"
android:textColor="@color/color_inter_color_font_button"
android:textSize="30dp" />
<Button
android:id="@+id/btnCheck"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="0.5dp"
android:layout_weight="0.4"
android:background="@color/color_inter_color_background_button"
android:gravity="center"
android:text="@string/btnCheck"
android:textColor="@color/color_inter_color_font_button"
android:textSize="30dp" />
<Button
android:id="@+id/btnNextWord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/color_inter_color_background_button"
android:gravity="center"
android:text="@string/btnNextWord"
android:textColor="@color/color_inter_color_font_button"
android:textSize="30dp" />
</LinearLayout>
</LinearLayout>
Answer the question
In order to leave comments, you need to log in
Set your Activity's AndroidManifest flag to windowSoftInputMode="adjustResize" and see the result. I think it should help.
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustResize">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/fragment_learn_words"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="96dp"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/ivWord"
android:layout_width="96dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginRight="0.5dp"
android:gravity="center"
android:src="@android:drawable/ic_dialog_dialer"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/tvWord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="0.5dp"
android:background="?attr/colorPrimary"
android:gravity="center"
android:text="empty"
android:textSize="35sp"
android:textStyle="bold" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_weight="0.4">
<EditText
android:id="@+id/etEnterWord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:background="@android:color/darker_gray"
android:gravity="center_horizontal"
android:hint="etHintEnterWord"
android:inputType="textNoSuggestions"
android:maxLength="15"
android:minLines="1"
android:textSize="35sp"
android:textStyle="bold" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginTop="1dp"
ads:adSize="BANNER"
ads:adUnitId="123456">
</com.google.android.gms.ads.AdView>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:layout_margin="2dp"
android:layout_marginTop="1dp"
android:orientation="horizontal">
<Button
android:id="@+id/btnHelp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="0.5dp"
android:layout_weight="1"
android:background="?attr/colorPrimary"
android:gravity="center"
android:text="\?"
android:textSize="30dp" />
<Button
android:id="@+id/btnCheck"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="0.5dp"
android:layout_weight="0.4"
android:background="?attr/colorPrimary"
android:gravity="center"
android:text="Проверить"
android:textSize="30dp" />
<Button
android:id="@+id/btnNextWord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/colorPrimary"
android:gravity="center"
android:text="->"
android:textSize="30dp" />
</LinearLayout>
</LinearLayout>
Wrap your layout in a ScrollView . And the keyboard won't cover the buttons.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question