Adjust the layout when the soft keyboard is on in android - android

I have an activity where the view is like a form, where user can enter the details and At the bottom there are two buttons "save" and "cancel". The form has many number of edit boxes.
So I have taken a relative layout and put all these edit boxes in it and then put the relative layout inside scroll view. I have taken another relative layout to add "Save" and "cancel" button.
Finally I have put the scroll view and relative layout(which has buttons) in another relative layout which is the main view of my activity.
My problem is , when I click any of the edit box, keyboard will come up and it hides the buttons(Save and Cancel).
I want to make the buttons to display above the keyboard(When the keyboard is on) like in the edit contact activity of "Contacts" Application .
I am using android:windowSoftInputMode="adjustPan|adjustResize" for my activity but of no use.
I have gone through so many stack overflow questions regarding this but I am not able to achieve this.
How can I do this with my code?

in Edit Contact activity save button is added to layout in bottom, and outside of scroll view.
What you can do, to make your save and cancel button visible all the time, wheather, soft keyboard is visible, or not. Make parent layout a relativelayout, in this layout add two views one scroll view, and other relativelayout having buttons. Let Relative Layout properties layout_width=fill_parent and layout_height=wrap_content, and align_parent_bottom=true, and scroll view's layout_width=fill_parent, layout_height=fill_parent, lavout_above=#+id/rlButtons, in ScrollView, add a RelativeLayout having all the editTexts.

I got the solution .
My parent layout is Relative Layout . In this layout I added a Scroll View and a relative layout. In the scroll view I added a relative layout which is having all edit texts. In relative layout I added save and cancel buttons. I set the scroll view weight = 1.
For my activity I set android:windowSoftInputMode="adjustResize".

Related

Touchable view across two layouts

I want to make a button which lays between two layouts. I make layout in layout. In inner layout I make a button and movi it outside the layout by setting negative margin. The button is not clickable outside the wrapping layout. How to fix that?

Android soft keyboard hides edit text decorator

Layout MockI have a decorated (Framed) EditText which I use in my app. When the soft keyboard comes up it hides the part of the frame that is below the text view. For the frame functionality I use a LinearLayout which contains the EditText.
Is there a way to set the keyboard not to hide the bottom part of the frame(The containing Layout)?
Edit: I guess I am not explaining myself properly. The Linear layout containing the EditText is not the main fragment layout, it is contained in it and is used as a decorator for it. what I am basically trying to do is set a margin between the keyboard and the EditText so that the keyboard doesn't hide the surrounding LinearLayout which is again, not the main layout for the fragment.
In the mock, the problem is that the keyboard goes up all the way to the bottom of the EditText and covers the bottom part of the wrapper layout. I need the entire wrapper layout to be seen. Any Ideas.
You have to wrap your linear layout within ScrollView with the following property android:fillViewport="true" and in manifest write down the following line of code `android:windowSoftInputMode="adjustResize".
Set all your Activity view or layout in ScrollView.
Which will make your view scrollup when soft keyboard open and it don't hide your view.

prevent only 1 view from coming up when keyboard is up

there are 2 views which are set to "align parent bottom" as true in my activity. One is a textview and other one is a linear layout. I want to display this linear layout only when keyboard is up, that too on the top of keyboard. The issue is like when i tap on the edittext, keyboard is up with linear layout on top that.But the textview is also coming up. I dont want that textview to come up.I just want that linear layout to come up when keyboard shows. Is it possible?then how?

Display rest of layout fields on button click on same View

I have layout containing 30 fields ( using editbox, spinners, buttons etc)
but it looks too weird with crowded elements. ( scroll view is also longer)
So i decided to keep 1 more button, so firstly 15 fields will display and 1 "More" button below,now i want to display rest of fields onClick "more" button on same layout ( below that 15 fields). How to do this, thanks in advance
I would suggest you to make a parent view with two main relative layouts. First relative layout for all the content you want to show at first time. Make this layout visibility View.VISIBLE. Second relative layout for all the content you want to show on click event. Make this layout visibility View.INVISIBLE.
On button click event make second relative layout visible by setting view.setVisibility(View.VISIBLE)
Don't forget the invisible the layout in the end. Otherwise it will be visible throughout the app session.
You can also set this property in your xml too. There is a android:visibility="visible" tag in every view.
This approach will help you in management because by setting a single view visibility you can manage your all view. Happy Coding!!

Android: How can I create a layout within a layout ?

In my app I want to have a button that if the user clicks it
than a new layout is opened within the current (acually the main) layout.
the new layout should not fill all of the screen and parts of the previous layout
should be grayed out.
Any ideas on how to do this ?
You can show a hidden layout within your button's onClick event by calling
view.setVisibility(View.VISIBLE)
You can also fade out view elements or whole views with
view.setAlpha(75);
view.setBackgroundColor(Color.GRAY);
Note that "view" in the first example is your layout element.. LinearLayout, RelativeLayout, etc. and in the 2nd example, "view" is the element(s) you're trying to gray out.
Follow the answer of SBerg413. And for more information. you can take the relativelayout for the part that you want to hide and display on the button click.
And as like SBerg413 answer. you can hide the respective layout and show the layout you want to display.
Hope it will help you.
Thanks.
you can use a ViewFlipper to achieve what you want, position the viewflipper where the child views should fit (part of the screen you say)..
Inflate the rest of the "child" layouts from other xml, add them to the flipper and switch between them when you want...

Categories

Resources