View with alignParentBottom attribute covering Edittext when keyboard opens - android

I have a Fragment with nested fragments, using a Viewpager. When the keyboard opens, the RelativeLayout covers the EditText
Is there any way to open the keyboard without the RelativeLayout go up?
Parent Fragment layout:
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#color/colorBackground"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/vp_service_creation"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="#+id/rr_semi_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="-180dp"
android:layout_centerInParent="true"
android:background="#drawable/half_circle_green"
android:layout_weight="1">
<dk.ostebaronen.droid.viewpagerindicator.CirclePageIndicator
android:id="#+id/pi_circles"
android:layout_marginTop="40dp"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_width="90dp"
/>
</RelativeLayout>
</RelativeLayout>

I have tried different approach for your case.
Option 1:
You can try adjustNothing, but the keyboard will potentially cover your EditText.
<application ... >
<activity
android:windowSoftInputMode="adjustNothing" ... >
...
</activity>
...
</application>
You can refer to the tutorial here
Option 2:
If you want to keep adjustPan for auto push the view up when the EditText is covered by the keyboard, I suggest you add a listener to detect the keyboard visibility. When the keyboard is visible, hide rr_semi_circle layout. When user finish input text and keyboard is hidden, show the rr_semi_circle layout again.

Add ScrollView at the following sample like that.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#color/colorBackground"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.v4.view.ViewPager
android:id="#+id/vp_service_creation"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="#+id/rr_semi_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="-180dp"
android:layout_centerInParent="true"
android:background="#drawable/half_circle_green"
android:layout_weight="1">
<dk.ostebaronen.droid.viewpagerindicator.CirclePageIndicator
android:id="#+id/pi_circles"
android:layout_marginTop="40dp"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_width="90dp"
/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Try this
android:windowSoftInputMode="adjustPan"
in your androidManifest.xml, this will not make the UX to resize the components inside but pan itself and give you the same output you desire.

Related

FloatingActionButton above keyboard and BottomNavigationView hidden under keyboard in Android

I'm faced with a problem I just can't wrap my head around. It's fairly straight forward;
I have a view in which I have an EditText, a FloatingActionButton and a BottomNavigationView. When I select the EditText the keyboard pops up. This is when I want the FloatingActionButton to float above the keyboard and the BottomNavigationView to stay hidden behind the keyboard.
I have tried using both android:windowSoftInputMode as adjustResize and as adjustPan. The former will make the FloatingActionButton and the BottomNavigationView stay hidden behind the keyboard. The latter will push both the FloatingActionButton and the BottomNavigationView up above the keyboard.
In addition to this I tried using a simple custom BottomNavigationView element that set it's own visibility to hidden when the keyboard is detected (using viewTreeObserver and addOnGlobalLayoutListener). This works in tandem with adjustResize, but there is a slight delay after the kayboard pops up where you can see the BottomNavigationView, making it look very "jumpy".
My question is now; Are there are alternative solutions to this?
Edit
This is my current xml, it's very straight forward.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:fitsSystemWindows="false">
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/navigation"
android:layout_margin="10dp"
android:layout_gravity="top|end"
app:layout_anchorGravity="right"/>
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
android:layout_gravity="bottom"
android:elevation="20dp"
app:menu="#menu/navigation" />
</android.support.design.widget.CoordinatorLayout>
The one thing that i use always to get rid of this problem.
Wrap your view inside ScrollView that you dont want to come up of keyboard.
Keep views outside Scrollview which you want float upon keyboard when keyboard opens.
Does not this sounds good and pretty easy :)
<?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"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/button_next"
android:background="#0ff"
>
// these views will not come up.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="250dp"
android:hint="Hint"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ABC"
android:textSize="50sp"
/>
</LinearLayout>
</ScrollView>
// this will float on keyboard
<Button
android:id="#+id/button_next"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:text="Button Next"
/>
</RelativeLayout>
in the manifest.xml
<application
...
>
<activity android:name=".YourActivity"
android:windowSoftInputMode="adjustResize"
>
</activity>
</application>
Edit:
Try this, it is used to move fab upon keyboard.
Add android:windowSoftInputMode="adjustResize" to your activity in manifest
Make sure your root view in layout xml, has android:fitsSystemWindows="true" property
change your main parent layout property android:fitsSystemWindows="false" to android:fitsSystemWindows="true" and put android:windowSoftInputMode="adjustResize" in your activity in AndroidManifest.xml file

Move elements in Layout when keyboard is shown

I inflate a pop-up layout, where I implement some kind of chat. At the bottom (align parent bottom) I have EditText, where I can type message. And I have a ScrollView with LinearLayout, that uses left space of a layout. Messages appear in ScrollView. The problem is how to move elements when keyboard is shown. For example, I tap on EditText and soft keyboard appears above EditText, so I don't see what I'm typing. How to move it?
I tried to use windowSoftInputMode in manifest with adjustResize or adjustPan but it didn't help.
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="320dp"
android:layout_height="500dp"
tools:context="shkatovl.osanka.MainActivity"
android:background="#drawable/border_popup"
android:focusable="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_marginTop="100dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="58dp">
<LinearLayout
android:id="#+id/llDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="58dp"
android:background="#drawable/rect8"
android:layout_alignParentBottom="true">
<EditText
android:id="#+id/etDialog"
android:layout_width="244dp"
android:layout_height="38dp"
android:textSize="16sp"
android:textColor="#color/font"
android:hint="Сообщение"
android:paddingStart="15dp"
android:textColorHint="#color/font40"
android:background="#drawable/rect9"
android:theme="#style/EditText"
android:text=""/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>

scrollview not scrolling to bottom of the screen

I have a difficulty with implementing scroll view while using Theme.Black.NoTitleBar.Fullscreen.
When the user opens the application and click on editText the keyboard opens but the user cannot scroll beneath the edittext.
After many attempts I figured it something to do with the theme I am using (fullscreen)
This is my code .xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:id="#+id/vieww"
android:layout_width="match_parent"
android:layout_height="1000dp"
android:background="#android:color/holo_green_dark" />
<EditText
android:id="#+id/test_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/vieww" />
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="#id/test_edit"
android:background="#android:color/holo_blue_bright" />
</RelativeLayout>
When the keyboard is opened the user cannot see the lowest view beneath the edittext.
What I tried so far:
I played a lot with windowSoftInputMode of the activity I tried combination of adjustResize/adjustPan but nothing seems to work.
I tried to change the container to LinearLayout but it still not working for me
I found a solution here here
The problem with this solution I need to change the minSdk to 19, when the application starts I can see black stripe where has been the title bar.
the other issue is when the user open the keyboard by pressing on edittext the title bar returns
I think you should put the ScrollView in a Relative Layout, so you can fit the size, if the keyboard appears.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:id="#+id/vieww"
android:layout_width="match_parent"
android:layout_height="1000dp"
android:background="#android:color/holo_green_dark" />
<EditText
android:id="#+id/test_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/vieww" />
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="#id/test_edit"
android:background="#android:color/holo_blue_bright" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

android scrollview not working windowSoftInputMode

I have one activity and in this activity's windowSoftInputMode is stateAlwaysHidden
android:windowSoftInputMode="stateAlwaysHidden"
i created custom Xml file and in this xml i have one edittext in top position and one button in bottom position
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:minHeight="#dimen/u_base_min_height">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:minHeight="#dimen/u_base_min_height"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/transfer_headerView_height">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:paddingLeft="#dimen/u_common_margin_left"
android:paddingRight="#dimen/u_common_margin_right">
<Button
android:id="#+id/u_done"
android:layout_width="fill_parent"
android:layout_height="#dimen/u_widget_height"
android:background="#drawable/rounded_corners_blue"
android:text="#string/u_register_next"
android:textColor="#ffffff"
android:textSize="#dimen/u_common_text_size" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/u_common_margin_left" />
</LinearLayout>
</RelativeLayout>
when keyboard is showing i can not show my button whitch is a bottom position,scrollview now working.
i searched about my problem and i tryed to change windowSoftInputMode in manifest file
android:windowSoftInputMode="adjustResize"
but i don't need this solution because my button moving keyboard up when my keyboard is showing...
how i can solve my problem? if anyone knows solution please help me
thanks everyone
put your bottom button outside the scrollview. Make two separate layouts. In upper layout put your scrollview content and in lower layout put your bottom button.
For that use below code
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true">

Webview not resizing when keyboard appears

Need to resize my webview similar to Cordova/Phonegap when keyboard appears.
Right now as per below code, My input text fields are getting overlayed by device keyboard. I want to squeeze height of webview and make it adjust height above device keyboard.
Activity code :
<?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:background="#drawable/bg_home">
<include android:id="#+id/head" layout="#layout/header" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="11dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
android:layout_marginTop="2dp"
android:layout_below="#id/head"
android:background="#drawable/overlay_bg2"
android:orientation="vertical"
android:padding="9dp" >
<WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:isScrollContainer="true"/>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleLargeInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible" />
</FrameLayout>
</RelativeLayout>
Manifest Entries :
Theme android:theme="#android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
Activity keyboard control android:windowSoftInputMode="adjustResize"
As far as I know, If your activity (or application as a whole) is set to full screen; android:windowSoftInputMode="adjustResize" won't work.

Categories

Resources