scrollview not scrolling to bottom of the screen - android

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>

Related

View with alignParentBottom attribute covering Edittext when keyboard opens

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.

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">

Android Keyboard showing resize activity

I'm trying to resize my activity when EditText become first responder and keyboard is showing.
For now I have used android:windowSoftInputMode="adjustResize"in my AndroidManifest.xml. It works great but when keyboard is showing I can see the previous activity in the background. Is that normal?
Both activities have white background so I'm wondering what am I doing wrong?
My second activity xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<TextView
android:id="#+id/topView"
android:background="#color/HWMMainColor"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="60dp"
android:padding="6dip"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLinearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0" />
</LinearLayout>
Thanks

how to change layout when soft Keyboard is shown

I have the following layout for an activity...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical"
android:fillViewport="true"
android:background="#3ba4a4a4"
android:fadeScrollbars="true">
<TextView
android:id="#+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textIsSelectable="false"
android:text="#string/test_text"
android:textSize="40sp"/>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="2dp">
<EditText
android:id="#+id/edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/edit_text_hint"
android:layout_marginTop="8dp"
android:theme="#style/InputMethodTheme"/>
<ImageButton
android:id="#+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_send"/>
</LinearLayout>
When the soft keyboard is opening I want the end of the TextView to go up with the EditText...
Any Idea on How to do That?
The EditText is going up normally as it should but its blocking the text view
i have tried the following in the manifest file in my activity
android:windowSoftInputMode="adjustPan"
But the action bar disappears which i don't want...
UPDATE
I tried the following in the TextView
android:layout_gravity="bottom"
and it seems to react as i want it to but some of the
lines before it are getting removed and extra spaces are
being added after the last word...
Basically you need to listen to the keyboard opening event.
More How to capture the "virtual keyboard show/hide" event in Android?
Be careful when dealing with devices with soft navigation buttons e.g., Nexus 5, you may need to take the navigation bar height into consideration.

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