I am trying to build a form using an EditText view that is nested in a ListView. There are a couple of levels of RelativeLayout and LinearLayout objects between the ListView and the EditText, but from what I've read this shouldn't be a problem.
I've tried all I can think of. I have set android:windowSoftInputMode="adjustPan" in the AndroidManifest for my activity, and I have set android:descendantFocusability="beforeDescendants" for my ListView as well. I have even set that for all layout objects between the ListView and the EditText. However, none of this seems to work.
The main issue I have is the soft keyboard doesn't show up, and even when I double tap the text field to pull up the editing options I still cannot type anything into the EditText area. Am I just flat out using the wrong object control for this?
This is the layout code for my ListView object.
<ListView
android:id="#+id/FormlistView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
style="#style/KelFormListView" />
This is the layout code for my form_list_item.xml file. This is the item that is displayed in the form list.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:descendantFocusability="beforeDescendants">
<!-- Top Layout -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:weightSum="10"
android:descendantFocusability="beforeDescendants"
android:id="#+id/TopLayout">
<TextView
android:id="#+id/TitleTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:gravity="center_vertical"
android:text="Headling Rent (pa)"
android:textSize="16dp"
style="#style/KelFormListItemLabel" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:weightSum="2"
android:descendantFocusability="beforeDescendants"
android:background="#color/formListItemValueBackgroundColor">
<ImageView
android:id="#+id/CurrencyIconView"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_weight="0"
android:src="#drawable/icon_currency_pound"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp" />
<EditText
android:id="#+id/ValueTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="right|center_vertical"
android:text="20,000"
android:textSize="16dp"
android:inputType="number"
android:focusableInTouchMode="true"
android:editable="true"
style="#style/KelFormListItemValue"/>
</LinearLayout>
</LinearLayout>
<!-- Bottom Layout -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:weightSum="10"
android:id="#+id/BottomLayout"
android:descendantFocusability="beforeDescendants"
android:layout_below="#+id/TopLayout">
<TextView
android:id="#+id/BottomTitleTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:gravity="center_vertical"
android:text="Headling Rent (pa)"
android:textSize="16dp"
style="#style/KelFormListItemLabel" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:weightSum="2"
android:descendantFocusability="beforeDescendants"
android:background="#color/formListItemValueBackgroundColor">
<ImageView
android:id="#+id/BottomCurrencyIconView"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_weight="0"
android:src="#drawable/icon_currency_pound"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp" />
<EditText
android:id="#+id/BottomValueTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="right|center_vertical"
android:text="20,000"
android:textSize="16dp"
android:inputType="number"
android:focusableInTouchMode="true"
android:editable="true"
style="#style/KelFormListItemValue"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Ok, figured out my own issue. The primary issue had nothing todo with any of my code. The problem was actually the emulator it's self. When creating a new virtual device in Android ADV there is a settings called "Enable Keyboard", or something along those lines. This setting allows you to use your hardware keyboard with the emulator, but it prevents the soft keyboard from showing up. That was my problem.
In my opinion this setting can easily cause confusion since it's not until you display the advanced settings that it appears. This just seems to me to be a poor decision that someone over at Google has made. Yet another reason why iOS development is easier...in my opinion of-course.
Related
I'm trying to make a chat layout. The problem is when I focus the EditText, softkeyboard appears and pushes everything up. I want it to push only bottom part with send instructions so that top (brown) header part and a recyclerview with messages are still visible. Something that facebook messenger app has. I tried putting "adjust pan, resize" and everything in manifest file, but it didn't work. Here is my default layout when nothing is in focus:
And this is when I press the EditText and keyboard appears and shifts everything up:
I can't see header anymore nor the message in recyclerView.
Basically I want all elements to stay visible at all times, so when Keyboard pushes up, header, messages and send are still visible to the user.
Here is my layout code:
<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">
<LinearLayout
android:id="#+id/ll_profile"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/iv_profile"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/img_back" />
<TextView
android:id="#+id/tv_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp" />
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/ll_profile"
android:fillViewport="true"
android:isScrollContainer="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/view_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:background="#color/gray_light_trans" />
<LinearLayout
android:id="#+id/ll_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="10">
<EditText
android:id="#+id/et_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
android:hint="Message" />
<Button
android:id="#+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/ll_send"
android:layout_below="#id/view_line" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
use android:windowSoftInputMode="stateHidden" in your activity at manifest
The issue was that I was using a theme in my App activity that was fullscreen. When I removed fullscreen from main base theme, it's working.
I have a custom Dialog as shown below:
When I click on the Edit Text, The dialog is shifted upwards but half of the dialog becomes invisible as shown below:
I verified the issue on Android ICS and Gingerbread but it doesn't happen on Android Lollipop.
I appreciate your help for figuring out why.
Here is the custom dialog layout XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layoutChatInGame"
android:layout_width="305dp"
android:layout_height="190dp"
android:background="#drawable/dialog_table_border"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/roomlist_title_background">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBar"
android:layout_margin="5dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_margin="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Game is on hold because the host paused the app"
android:id="#+id/lblOnHoldDialogMessage"
android:textColor="#color/progress_dialog_on_hold_text"
android:textSize="18dp"
android:singleLine="false"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/lblChatHistoryGameOnHold"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="bottom"
android:maxLines="5"
android:scrollbars="vertical"
android:textColor="#color/edit_text_general_text"
android:textColorHint="#color/edit_text_general_hint"
android:paddingRight="2dp"
android:paddingLeft="2dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/textChatGameOnHold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_weight="1"
android:ems="10"
android:hint="#string/edit_text_send_chat_message"
android:imeOptions="flagNoExtractUi|actionDone"
android:inputType="text"
android:maxLength="100"
android:maxLines="1"
android:textColor="#color/edit_text_general_text"
android:textColorHint="#color/edit_text_general_hint"/>
<Button
android:id="#+id/btnSendGameOnHold"
style="#style/lightboxButton.Blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendChatMessageInGame"
android:text="#string/btn_send"/>
</LinearLayout>
</LinearLayout>
Try to use also android:imeOptions="flagNoFullscreen" in your .xml. Recommend you to make some tests, using it with and without flagNoExtractUi. Please give me some feedback.
If all the other solutions are not working then try adding marginBottom in the top layout:
LinearLayout android:layout_marginBottom=20dp
You can get the desired behavior by making adjustResize flag for the windowSoftInputMode of the dialog in the manifest if your dialog is declared as an activity.
Like This:
android:windowSoftInputMode="adjustResize|stateHidden"
You can also directly try something like this directly on the dialog:
alertDialog.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
I have relative layout. Within which I have many views like edit text, text views and so on. I do lots of animations in that. Everything was perfectly fine. But at one point, I have a requirement.
It is the password page. Create and confirm password. Two edittexts one after another. If the password doesnt meet the requirement, a plain orange view should slide up with error message "Invalid password".
So I put create and confirm password in linear layout. The linear layout will slide up, letting user type in passwords. After validation, if there is an error, the linear layout should slide down and the plain view will slide up. I kept the view invisible and when required I made it visible and wrote the code to slide up. The same code works when I just use single edit text instead of linear layout. But it is not working when using linear layout. Am I doing something wrong?
Adding code to it. The code specific to this issue starts with till the end of coding
I declared linear layout as view and NOT VIEWGROUP.
EDIT: After doing analysis, I found that the view I am trying to slide up after sliding down the layout is hidden somewhere in the view hierarchy.
view.bringToFront() helps to bring the error view to the front and slides up.
But after that the problem is, after my linear layout slide down, the error view is not sliding up straight away. Because I am using bringToFront(), it displays the view first on the whole screen (with background color as orange) and then the sliding starts.
I am not sure whether it is correct but I fixed this issue like this.
no background color has been given to the view
I used errorView.bringToFront () and errorView.setVisibility(true) in the animationEnd() of a Layout slidingdown animation listener.
I defined sliding up animation for the errorView in the same animationEnd() of layout sliding down listener
In the animationStart() of errorView sliding up animation listener, I defined the background color of the errorView. Now its working as expected.
But let me know better way of doing this.
//Declaration
View greyView, orangeView, yellowView, blueView, orangeErrorView, letsGetStartedView, welcomeBckView, passwordMasterLayout, orangePwdErrorView;
TextView welcomeText,errorTextView, letsGetStartedTextView, welcomeBckTxtView, errorPwdMsg;
//Password Error Handling
orangePwdErrorView = v.findViewById(R.id.orangePasswordErrorView);
errorPwdMsg = (TextView) v.findViewById(R.id.errorPasswordMessage);
//Layout code
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/sample_main_layout">
<FrameLayout
android:id="#+id/sample_content_fragment"
android:layout_weight="76.4"
android:layout_width="match_parent"
android:layout_height="0px" />
<FrameLayout
android:id="#+id/bottomPanel"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="23.6">
</FrameLayout>
</LinearLayout>
sample_content_fragment framelayout takes the below code
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<View
android:id="#+id/grey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#58595B" />
<View
android:id="#+id/orange"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F26724"
android:visibility="invisible" />
<View
android:id="#+id/yellow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FDB518"
android:visibility="invisible" />
<View
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1893D2"
android:visibility="invisible" />
<TextView
android:layout_width="260dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/welcome"
android:id="#+id/welcomeTextView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="51dp"
android:textColor="#ffffff"
android:textSize="20dp"
android:textStyle="bold"
android:visibility="invisible"
/>
<ImageView
android:layout_height="60dp"
android:layout_width="60dp"
android:id="#+id/clinicloud_logo"
android:clickable="true"
android:src="#drawable/clinicloud_icon"
android:layout_marginRight="50dp"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="40dp" />
<View
android:id="#+id/orangeErrorView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F26724"
android:visibility="invisible" />
<EditText
android:layout_width="match_parent"
android:layout_height="90dp"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/emailEditText"
android:text="#string/enter_email"
android:layout_gravity="center"
android:background="#f4f4f4"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:visibility="invisible"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/errorMessage"
android:layout_alignTop="#+id/welcomeTextView"
android:layout_centerHorizontal="true"
android:textColor="#ffffff"
android:visibility="invisible"/>
<!--UI components for welcome back page-->
<View
android:id="#+id/welcomeBackView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#134F9F"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/welcome_back"
android:id="#+id/welcomeBackTxtView"
android:textColor="#ffffff"
android:layout_alignTop="#+id/welcomeTextView"
android:layout_alignStart="#+id/clinicloud_logo"
android:textSize="20dp"
android:textStyle="bold"
android:visibility="invisible"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="90dp"
android:ems="10"
android:id="#+id/password"
android:layout_alignTop="#+id/emailEditText"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:text="Password"
android:visibility="invisible"
android:background="#d2d1d1"
/>
<!--UI components for Let's get started page-->
<View
android:id="#+id/letsGetStartedView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#5C3A91"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Let's get started"
android:id="#+id/letsGetStartedTxtView"
android:textColor="#ffffff"
android:layout_alignTop="#+id/welcomeTextView"
android:layout_alignStart="#+id/clinicloud_logo"
android:textSize="20dp"
android:textStyle="bold"
android:visibility="invisible"/>
<!--Linear layout to show the create and confirm password-->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="180dp"
android:gravity="bottom"
android:layout_alignBottom="#+id/emailEditText"
android:layout_alignParentStart="true"
android:weightSum="1"
android:id="#+id/passwordMasterView"
android:visibility="invisible">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:id="#+id/createPwd"
android:layout_weight="0.50"
android:background="#F4F4F4"
android:text="#string/create_password"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:id="#+id/confirmPwd"
android:layout_weight="0.50"
android:background="#E3E3E3"
android:text="#string/confirm_password" />
</LinearLayout>
<!-- To show password errors-->
<LinearLayout
android:id="#+id/orangePasswordErrorView"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F26724"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/errorPasswordMessage"
android:layout_alignTop="#+id/welcomeTextView"
android:layout_centerHorizontal="true"
android:textColor="#ffffff"
android:visibility="invisible"
/>
<!-- To show password errors-->
</RelativeLayout>
The java logic is in https://stackoverflow.com/questions/30523599/sliding-up-and-down-android
Please direct for any incorrect codings
I kept the view invisible and when required I made it visible and wrote the code to slide up.
I think you must do it in DialogFragment or custom AlertDialog that will be shown above your layout, if dont want to do this try envelop your RelativeLayout in FrameLayout and adding in it LinearLayout for example but visout your code difficult to say in what problem it is
You should consider using a library for the sliding panel, one that I've had excellent experiences with (and supports the functionality that your after) is umano's AndroidSlidingUpPanel. https://github.com/umano/AndroidSlidingUpPanel
I have a simple layout with:
top bar (like action bar) with save and back button
and below a scroll view with some EditText inside... (check the image below),
When I call keyboard, my view is push above... I would like my Top Bar to stay always visible and fixed on the top... (check below the image of what is happening and what I would like to happen)
I tried several solutions with android:windowSoftInputMode, putting the top bar as relative layout and set isScrollContainer in scrollview but none have worked for me...
Code Below:
<RelativeLayout
android:id="#+id/llWriteCommentWall"
style="#style/TextSubSeparator"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="#style/TextSubSeparator"
android:layout_marginBottom="#dimen/margin_separator_bottom"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="left|center_horizontal|center_vertical"
android:orientation="horizontal"
android:layout_marginTop="#dimen/margin_title_top"
android:layout_marginBottom="#dimen/margin_title_bottom"
android:layout_marginLeft="#dimen/margin_title_left"
android:layout_marginRight="#dimen/margin_title_right"
>
<ImageView
android:id="#+id/ivMainMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/tk_btn_home"
android:onClick="clickHome"/>
</LinearLayout>
<TextView
android:id="#+id/tvSeconHeader"
android:text="#string/title"
android:layout_width="match_parent"
android:layout_weight="2.5"
android:layout_height="match_parent"
android:gravity="center"
style="#style/TextTileHealth"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="right|center_horizontal"
android:orientation="horizontal"
android:layout_marginTop="#dimen/margin_title_top"
android:layout_marginBottom="#dimen/margin_title_bottom"
android:layout_marginLeft="#dimen/margin_title_left"
android:layout_marginRight="#dimen/margin_title_right">
<ImageView
android:id="#+id/ivSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/tk_btn_tab_save"
android:onClick="clickSave"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:isScrollContainer="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_separator_bottom"
android:gravity="center">
<!-- EditBoxes -->
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="#+id/et1"
style="#style/TextEditBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:inputType="numberDecimal"
android:maxLength="3"
android:layout_weight="0.33"
android:gravity="center"
android:ems="3"
android:layout_marginBottom="10dp"/>
<EditText
android:id="#+id/et2"
style="#style/TextEditBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:inputType="numberDecimal"
android:maxLength="3"
android:layout_weight="0.33"
android:gravity="center"
android:ems="3"
android:layout_marginBottom="10dp"/>
<EditText
android:id="#+id/et3"
style="#style/TextEditBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:inputType="numberDecimal"
android:maxLength="3"
android:layout_weight="0.33"
android:gravity="center"
android:ems="3"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
And Manifest:
<activity
android:name="com.example.slyzer.gui.new.NewValue"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait">
</activity>
EDIT:
I recently find out, that when you put the activity as Full Screen:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
, the windows starts to act different from usual:
https://code.google.com/p/android/issues/detail?id=5497&q=fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
and as described by Dianne Hackborn in here, this is how it's working, and it seems that there is no interest in changing it.
So, I tried the Joseph Johnson's AndroidBug5497Workaround, but I always end up with a "extra" blank bar above my keyboard, and the View steel doesn't show as I want it to...
Does anyone have a nice/simple solution to this problem?
android:windowSoftInputMode="adjustResize" in the manifest for your activity will keep the top bar in view and resize the scrollview to use what room is left.
The only issue I can see with this would be lining up the edit text with the viewable area after it has been resized (if this is needed)
Add this to the activity tag in the manifest:
android:windowSoftInputMode="adjustPan"
Or programmatically:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
I have this layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/viewer_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_dark"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="3dp"
android:layout_weight="1" >
<EditText
android:id="#+id/viewer_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_filter"
android:background="#android:color/white"
android:drawableLeft="#android:drawable/ic_menu_search"
android:inputType="text"
android:paddingLeft="4dp"
android:selectAllOnFocus="true" >
</EditText>
<ImageView
android:id="#+id/viewer_filterX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/viewer_filter"
android:layout_alignRight="#id/viewer_filter"
android:src="#android:drawable/ic_menu_close_clear_cancel"
android:visibility="invisible" >
</ImageView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<EditText
android:id="#+id/viewer_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_search"
android:background="#android:color/white"
android:drawableLeft="#android:drawable/ic_menu_search"
android:inputType="text"
android:paddingLeft="4dp"
android:selectAllOnFocus="true" >
</EditText>
<ImageView
android:id="#+id/viewer_searchGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/viewer_search"
android:layout_alignRight="#id/viewer_search"
android:src="#android:drawable/ic_menu_send"
android:visibility="invisible" >
</ImageView>
<ImageView
android:id="#+id/viewer_searchX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/viewer_search"
android:layout_toLeftOf="#id/viewer_searchGo"
android:src="#android:drawable/ic_menu_close_clear_cancel"
android:visibility="invisible" >
</ImageView>
</RelativeLayout>
</LinearLayout>
<HorizontalScrollView
android:id="#+id/viewer_hscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/viewer_top" >
<ListView
android:id="#+id/viewer_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</HorizontalScrollView>
</RelativeLayout>
When I click on either EditText it expands to this dialog:
On portrait mode the EditTexts can be edited as they are without expanding. The XML for portrait is similar, only the EditTexts are one below the other and are screen wide.
How do I prevent this EditText expansion?
Not only the full phone screen is hidden by the EditText + virtual keyboard, but the clickable images the I put over the EditText are not visible.
I tried to set the EditText layout_width to 0dp, but they don't show.
I am not using SearchViews because they steal the focus and I cannot use the back key to go back to the previous activity.
Update
I removed the layout-land XML and used the same XML for both portrait and landscape.
In portrait mode it is fine, no expansion, in landscape mode there is expansion.
So it has to do somehow with being in landscape mode.
add this line to your edit text
android:imeOptions="flagNoFullscreen"
edit text look like this
<EditText
android:id="#+id/viewer_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint_filter"
android:background="#android:color/white"
android:drawableLeft="#android:drawable/ic_menu_search"
android:inputType="text"
android:paddingLeft="4dp"
android:selectAllOnFocus="true"
android:imeOptions="flagNoFullscreen">
Try to use android:maxLines="1" for EditText
I had similar issue. You can use mEditText.setSingleLine(true); where you are using it. This will solve your problem.
Hi please add this line in java code where your edit text is declared description.setMaxLines(1);
This post addresses the same problem and has the solution
Need to add
android:imeOptions="flagNoExtractUi"
to prevent this behavior.
If someone knows how, please mark this post as duplicate.