0

I'm working on an Android app (API 14 - 21), where the layout is like so:

-----------------------
|  Layout 1           |
-----------------------
| X | Layout 2        |
-----------------------
|                     |
|                     |
|  Layout 3           |
|                     |
|                     |
-----------------------

When the "X" is clicked, I need Layout 3 to slide off screen to the bottom, the soft keyboard to pop up, the "X" and Layout 2 to slide down (but maintain size) to be just above the soft keyboard, and Layout 1 to expand downward to fill any extra space. So it looks like this

-----------------------
|                     |
|  Layout 1           |
|                     |
-----------------------
| X | Layout 2        |
-----------------------
|                     |
|  Soft Keyboard      |
|                     |
-----------------------

I tried to have a RelativeLayout as the main layout for all the others. I had Layout 1 aligned top/left of parent, the "X" + Layout 2 container aligned left and layout_above to Layout 3, and Layout 3 aligned to bottom/left parent. I figured if I set Layout 3 to VISIBLE/GONE in code, that would do it. Instead, Layout 3 just disappears, everything else stays in place, and I see a white background where Layout 3 was.

Any ideas on how I can achieve this effect?

3 Answers 3

0

Did you try resize the layout 1 and layout 2 to fullscreen after setting the layout3 to GONE?

Sign up to request clarification or add additional context in comments.

Comments

0

Add your entiry screen inside a ScrollView. Android will span up to the focused view.

1 Comment

That's not really the effect I want.
0

It sounds as if you are already able to detect when a softkeyboard is displayed, and can tell Layout3 to hide itself at that time (View.Gone).

The reason for the white background is likely that you set Layout1 and layout2 with fixed height settings, and when you tell layout3 to be gone, they aren't expanding to take up the available room, hence you see the white backgorund of the parent ViewGroup.

2 Comments

I have set Layout3 to layout_height="0dp" with layout_weight="1" (no weightSum specified anywhere in the xml file), but the rest are set to wrap_content. So, any thoughts on how I force the other two to fill the available space? I want Layout2 to stay the same height and Layout1 to expand.
could you edit your question to include your full xml file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.