I use the Android Studio Navigation Drawer Project with one MainActivity and multiple Fragments which are replacing the container inside my MainActivity.
Sometimes when I open my software keyboard the Floating action button appears above the keyboard and sometimes the keyboard covers the fab. Does somebody know why?
It seems that somehow/sometimes your layout is not correctly changed. You should try to use android:windowSoftInputMode="adjustResize" in your activity tag in the manifest.
That should resize the content to the size above the keyboard and therefore the FAB should be always above.
From a UX point of view: Maybe you change the "submit" functionality and move it from a FAB to the toolbar (like the gmail app does). So FAB for a "new" or "add" functionality and as soon as the user can provide input, you show a "send"/"submit" button in the toolbar.
Related
I am working on Floating Action Bar on top of keyboard if user clicks on one of the EditText. I couldn't start on it and that's why not have any code to present.
I am confused on how to approach this problem. I am considering to use bottom sheet but I am still not getting confidence on it (I think android should have something better to use as base for this view).
I don't need any code snippet but need a direction. I am new to Android and before jumping to implementation, I needed a direction to start with.
Any suggestions? I am implementing
something similar to Outlook app.
So this floating toolbar is just a view that contains icons to press. This view should be located as the bottommost view on the screen. If you're using a ConstraintLayout use app:layout_constraintBottom_toBottomOf="parent".
And the android:windowSoftInputMode for hosting activity can be set to adjustResize (doc).
So when the keyboard opens it pushes this bottommost view up (and now this view is right above the keyboard).
I have an activity with BottomNavigation. If the user needs to click on the submit button soft keyboard hides it. Then he again needs to press the back button to see the submit button. In this case, I used windowSoftInputMode='adjustResize' so that the screen gets resized automatically and the user can scroll up and click on the submit button.
But, I have BottomNavigation too, windowSoftInputMode='adjustResize' makes BottomNavigation float above the soft keyboard. Can anyone suggest a better solution? Any help will be appreciated. Thanks
Thats tricky issue... You have two options in here:
Keep 'adjustResize' and hide BottomNavigation view when keyboard pops up (e.g. simply setVisiblity?)
Change to e.g. 'adjustPan' (or any other) preventing keyboard resizing app and add bottom padding with height of keyboard for whole content container. BottomNavigation will stay hidden under keyboard, but padding will allow scrolling to Submit button
In both cases you need to detect open/close keyboard, in second case you will also need keyboard height measuring. IN HERE and HERE you have big SO topics about this case, check out answers and comments, and pick proper resolution for your purposes
I have an EditText element at the bottom of the screen (like Whatsapp i.e), and I'm using android:windowSoftInputMode="adjustPan" in order not to hide the EditText when the keyboard appears. It works fine, it pushes the whole layout up so that the EditText can be seen.
Now, the problem is that when I select the text, the action mode bar doesn't appear, as if it was pushed up along with the layout.
I'm not using an explicit action bar in my layout, it's the one that appears on pre M devices when a text selection is made.
The layout hierarchy goes like this:
<FrameLayout>
<GLSurfaceView/>
<EditText/>
</FrameLayout>
So all I want to do is this action mode to keep it's position even when the keyboard is opened, using the pan behaviour.
adjustResize doesn't work for me. When set, the keyboard is over the EditText, and nothing resizes, probably due to GLSurfaceView.
Thanks!
I have a TabActivity which has the tabs across the bottom of the screen. My first tab hosts an activity which consists of a fixed header layout at the top of the screen, and a ScrollView beneath it which contains several EditText controls. The ScrollView scrolls it's content fine between the header bar and the bottom tabs, the problem occurs when an EditText is tapped and the soft keyboard appears. I understand to control the behaviour of the views when the keyboard appears I need to use the windowSoftInputMode attribute in the manifest XML file. However I've tried both the following settings :
adjustResize - Gives the correct functionality for the ScrollView and the header layout remains fixed at the top of the screen. However the tab bar controls are pushed up on top of the keyboard.
adjustPan - The tab bar controls remain at the bottom of the screen beneath the keyboard (which is what I want) but the other views are pushed up by the keyboard meaning the header layout gets pushed up off the screen.
It seems I need characteristics of both settings, but they can't be used together. I've heard of the setting adjustNothing but if I try this my project fails to build as it doesn't recognise this setting. I guess I need my tab host activity to have adjustPan but my content activity to have adjustResize but it seems you can't combine the two as it's the tab host activity that takes precedence.
Any help greatly appreciated.
In the absence of any direct solution for this, I have resorted to a kind of hack. I have set my TabHost activity to adjustResize and then written code to hide/unhide the tab bar controls (TabWidget) when the soft keyboard appears/disappears. I managed to get a pretty good result in the end, using the technique here : Adjust layout when soft keyboard is on to detect the keyboard appearing/disappearing.
In my Android application running in a XOOM device, when I click in an Edittext the keyboard opens and hides the Actionbar. I don't want this to happen, how can I solve this? This is done by the Google Contacts app for the tablet for example.
EDIT:
I have several edittexts in which the user needs fo fill. At first, when the user clicked on one edittext on the bottom, the keyboard showed up and hide the edittext in which the user was typing, so he couldn't see what he was typing. I found it really bad, and to solve it I just added to the manifest: android:windowSoftInputMode="stateVisible|adjustPan"
But after that, now the screen adjust itselfs and hides the action bar.
The Google Contacts app does the same, but it magically doesn't hide the Action bar. How do they do it?
Use adjustResize instead of adjustPan. The framework will always try to keep the focused element on-screen by scrolling any parent views if necessary.
If your EditText field is not nested in some sort of scrolling container such as a ScrollView then your layout may be too tall to completely display when the keyboard resizes your activity. Try wrapping your form's layout in a ScrollView. This will also allow your app's content to scroll if it is running on a smaller screen device where it may have similar issues.