EditText going beyond the window bound when keyboard comes in Android - android

In my manifest.xml I have set this to my current Activity.
<activity
android:name=".StockAdjustment"
android:theme="#style/CustomActionBarTheme"
android:label="#string/Metrix"
android:windowSoftInputMode="adjustResize" >
</activity>
my problem is when the keyboard appears my EditText going up too much. It beyond the view's upper bound and cant even see what I am typing.
No matter whatever I put for android:windowSoftInputMode="adjustResize" the same result comes.
Please help me.
Thanks
UPDATE
UPDATE 2
<ScrollView
style="#style/ScrollViewBase.Normal.Vertical"
android:layout_weight="1"
tools:isScrollContainer="false">

Set android:windowSoftInputMode="stateVisible|adjustPan|adjustResize"
Also, if you have a ScrollView in your layout, add android:isScrollContainer="false" to your ScrollView

Try this and also set the android:fitsSystemWindows="true" to parent layout element.
<ScrollView
style="#style/ScrollViewBase.Normal.Vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:isScrollContainer="false">

Finally I achived this my changing the structure of my layout.xml.
I changed my layout xml file into this
<LinearLayout style="#style/LinearBase.Normal.Vertical" >
<ScrollView
style="#style/ScrollViewBase.Normal.Vertical"
android:layout_weight="1"
android:fitsSystemWindows="true"
tools:isScrollContainer="false">
<LinearLayout style="#style/LinearBase.Normal.Vertical">
<LinearLayout
android:id="#+id/table_layout"
style="#style/LinearBase.Normal.Vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
style="#style/TextViewBase.Title"
android:tag="SCREEN_LABEL"></TextView>
<TextView
style="#style/TextViewBase.Emphasis"
android:tag="SCREEN_TIP"></TextView>
</LinearLayout>
<ListView
android:id="#+id/serialList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
<include layout="#layout/stock_adjustment_menu_bar" />
</LinearLayout>
Previously, my Scrollview is shrinking/paning, then the ListViewgoing up and I cant see the content inside the ScrollView. After I changed the layout structure, my whole content(Textviews,EditTexts adding by the code and ListView) is inside a single ScrollView. So shrinking/paning happens by considering the whole content of inside the Scrollview.
Make sure to disable the scrolling for parent view when touch the ListView

Related

Android Scrollview Won't fill parent space

I have a relative layout fills the entire screen. I want to add a scrollview in the middle of it to wrap a bunch of content so that I can make it pan up when the soft keyboard gets displayed. However, as soon as I wrap it in a scrollview, the bottom most layout stops filling the remainder of the screen.
Here is the XML where I have the ScrollView commented out.
<include
android:id="#+id/top_bar_with_save_button"
layout="#layout/top_bar_with_save_button"/>
<FrameLayout
android:id="#+id/log_entry_title_frame"
android:layout_below="#id/top_bar_with_save_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/log_entry_title_frame"
android:layout_alignParentBottom="true">
<!--
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/log_entry_title_frame"
android:orientation="vertical"
android:background="#f00">
<!-- Lots of stuff in here -->
<EditText
android:id="#+id/log_entry_notes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:gravity="top|left"/>
</RelativeLayout>
<!--
</ScrollView>
-->
</LinearLayout>
It looks like this:
But as soon as I remove the comment from the ScrollView it immediately compresses like this:
Why does this happen? I need it to fill the entire space on the screen, and I cannot figure out what is happening. Can anyone tell me how to fix this? Thanks!
You need to add the fillViewport="true" attribute to your ScrollView tag. Or you can add it programmatically with scrollView.setFillViewPort(true);. Otherwise, the ScrollView will wrap to its child's content height.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
... >
layout_height of scrolling container should be "wrap_content".

android questions about poping the soft keyboard

i want the whole layout move up to show while popping the soft keyboard, but the button on the bottom of the view cannot be seen.
the AndroidManifest.xml:
<activity
android:name="cn.duckr.android.plan.PlanConfirmPaymentActivity"
android:windowSoftInputMode="adjustPan"
style="#style/base_activity_style"
android:theme="#style/confirm_payment_anim_theme" />
To ensure that the system resizes your layout to the available space—which ensures that all of your layout content is accessible (even though it probably requires scrolling)—use "adjustResize".
link
android:windowSoftInputMode="adjustResize"
You can put whole layout except the particular button in a ScrollView to achieve this.
like this
<?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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView5"
android:fillViewport="true">
//put your contents here..
</ScrollView>
<ImageButton
android:id="#+id/ibSample"
android:layout_width="50dp"
android:layout_height="50dp"
android:adjustViewBounds="true"/>
</RelativeLayout>

Softkeyboard hides elements of my layout that I want to be visibles

I've got a layout that looks like first image and when I open the softkeyboard looks like the second image, but I want it how it seems on third image:
I read a lot about adjustpan and adjustresize on the manifest but nothing works, the xml structure is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blanco"
android:gravity="top"
android:orientation="vertical"
android:weightSum="10" >
<!-- LOGO -->
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.7"
android:background="#color/green_logo"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="65dp" >
<ImageView
android:id="#+id/logo_registro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/logo_registro" />
</LinearLayout>
<FrameLayout
android:id="#+id/contentFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6.3" >
</FrameLayout>
</LinearLayout>
First part is the green part with the app logo and inside the FrameLayout I put Fragments that contains simple LinearLayouts or RelativeLayouts with parts of my Login forms.
Put this on your Manifest, inside the activity
<activity android:name=".YourActivity"
android:configChanges="keyboard|keyboardHidden"></activity>
Set your windowSoftInputMode in your manifest for this activity to be adjustResize. THere are 3 possible settings for this- nothing, resize (shrinks your app to fit the remaining space), and pan (scrolls your app so the focused field remains on screen).
Just Add the empty scrollview and it will work
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>

ScrollView does not work with ActionBar

ScrollView does not work, I have a layout with some components like EditText, and when I'm typing something EditText keyboard rises, and along the component, however it appears above the other, the ScrollView does not respond to their function.
Already googled, and found some similar problems, but none solved my problem.
Below my layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbars="none" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
<TextView
android:id="#+id/txtDescricaoDocumento"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/edtDescricaoDocumento"
android:layout_alignBottom="#+id/edtDescricaoDocumento"
android:gravity="right"
android:text="Descrição:"
android:textAppearance="?android:attr/textAppearanceMedium" />
...
And my manifest.xml
<activity
android:name=".LancarDocumentoAcaoActivity"
android:windowSoftInputMode="adjustResize" >
</activity>
Couple things I've tried this without the relative layout inside of the scroll view...and scroll view worked perfectly.
1.Is relative layout necessary inside a linear layout? Try removing it if not.
2.Is the attribute WindowSoftInputMode necessary for the corresponding class if not you will have the soft keyboard covering view elements like it is mentioned.
Let me know if this works.

Forcing adjustPan in activity containing ScrollView

My layout looks like this:
<RelativeLayout>
<RelativeLayout>
</RelativeLayout>
<ViewFlipper>
<ScrollView>
<LinearLayout>
<EditText />
</LinearLayout>
</ScrollView>
</ViewFlipper>
<RelativeLayout>
</RelativeLayout>
</RelativeLayout>
When focused on the EditText in the middle, the soft keyboard pops up as expected, However it always resizes the layout even though I have android:windowSoftInputMode="adjustPan" in the manifest.
The problem with resizing is that only the ScrollView shrinks, leaving the RelativeLayouts above and below it intact, which can almost completely obscure the EditText.
I've tried hiding the RelativeLayouts when the keyboard is shown (that's another sad story), but adjustPan sounds more suitable. However it has no effect on this activity.
How can I force adjustPan to work despite the presence of the ScrollView?
Update:
SO won't let me answer my own question, but the solution is setting android:isScrollContainer="false" on the ScrollView.
Good question mostly Developers do the same thing but this is not a correct way you have need to do. This will help you.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ViewFlipper>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<EditText />
</LinearLayout>
</ScrollView>
</ViewFlipper>
<LinearLayout>
You should take LinearLayout with orientation as Vertical or horizontal view where you have never adjustment problem created.this is very simple.
try this in your manifest's the activity tag:
android:windowSoftInputMode="stateVisible|adjustPan"

Categories

Resources