Android Implement two fragments that have different behavior when keyboard appears - android

I have an activity which holds 2 fragments, FacebookFragment and GoogleFragment.
Now when activity is launched it launches FacebookFragment. When user presses a button on FacebookFragment the activity shows GoogleFragment which will be added in the container and the GoogleFragment has transparency so that the user can see the contents of FacebookFragment.
In the second fragment GoogleFragment I have an EditText that is at the bottom of the view and when the keyboard appears I want the EditText to be shown above keyboard.
But on the other hand I want that when the keyboard appears the view in FacebookFragment to stay as it is and not to be scrolled or resized from the keyboard.
What I have tried so far is that for the activity I have added in manifest:
android:windowSoftInputMode="stateHidden|adjustNothing"
and in FacebookFragment I have added:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
in GoogleFragment I have added:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
But this isnt working for me but I had to try that.
I have tried some answers that I have found here in stackoverflow but I haven't found the right solution.
Any solution is welcomed!
Thanks
PS: Activity has one FrameLayout container and both fragments are added to the same container.

Related

Android soft keyboard creates space in all fragments above activity

I am having an activity with a view pager which has four pages. In page1, I click on a view which opens another fragment above it. Now this fragment has edittext when user click on it for typing, the soft keyboard opens and it takes lot of time resizing the layout. I found out that keyboard is creating space in all the backstack fragments and that's why current fragment is taking this much time. Can you please suggest how can I force android keyboard to create space only in current fragment not in all fragments above the activity.

How to blur the Parent Activity when a fragment is added?

An Activity which has an image when i click the image
1)A fragment should be added in the middle of the parent activity
2)When the fragment appears the background of parent activity should get blurred/dimmed.
3)And clicking outside the fragment the fragment should disappear again.
(Same effect we get when we click contact image in whatsApp it opens an overlay)
I have can add fragment successfully but the activity remains active.
How to achieve this effect?
I have tried fragmentTransaction.setCustomAnimation(int,int) but it does not work.
Thank you.
You have two options:
Use a DialogFragment setting the layout in the onCreateView() method.
Add a full screen Fragment with a background with alpha (for example #44000000). Add the OnTouchListener to the background view and in the onTouch() method, dismiss the Fragment.
By the way, I would seriously recommend you the first option.

Adding a fragment on top of another fragment and clear focus of bottom fragment

I have created one fragment from the activity. After that I have added another fragment top of the previous fragment. I have added Android: clickable="true" in my top fragment so that I can grab the click event. Everything is working fine. Now I am trying to implement the external Keyboard navigation and found that bottom fragment still grab the focus.
I have tried different ways to clear the focus of bottom fragment when I am in the top fragment. But could not find a solution.
I solved the issue. I just invisible the bottom fragment from the top using findFragmentBytag to find the bottom fragment.
Example code segment:
Fragment bottom = ( Fragment) getFragmentManager().findFragmentByTag(bottom.TAG);
if (bottom.isVisible()) {
bottom.getView().setVisibility(View.INVISIBLE);
}

onBackPressed and Fragments

PROBLEM
I've MainActivity with onBackPressed overridden that holds SearchFragment within and FrameLayout for DetailsFragment(its an XML for Master/Detail 600dp-land).
Normally the DetailsFragment appears in its own Activity but on tablets its in FrameLayout.
This DetailsFragment have additional View that is normally hidden but might be shown via user interaction.
What I need is determine first whether View must start animating(closing) or leave Fragment.
I want to achieve closing this additional View before leaving the DetailsFragment with onBackPressed.
I have no idea how to solve this problem!
Please help me.

how to block UI from coming up on softkeyboard display

I am using same activity for multiple fragments. every fragment there is a searchview. Except home fragment in all other fragment we display listviews. In home fragment i have linear layouts to display some buttons and footer view. And when i type something in searchview in the home fragment it will display listview.i want to resize my screen when keyboard is up. So i have used below mentioned tag in manifest file for the actvity.
android:windowSoftInputMode="adjustResize"
It is wokring fine in all the fragments except home fragment. In home fragment when i tap on searchview(before typing.ie still displaying the buttons) the screen including the footer view is up. No issues with layout contains buttons. becuase it is scrollable. But topmost layout is not visible fully. Is it possible to stop it from pushing the footer layout to top in this fragment?

Categories

Resources