I use a Modal Bottom Sheet to allow the user to enter some text and create Decisions or Tasks.
Some users want to close the keyboard and they tap outside of the Bottom Sheet and close it. This is a big issue because all the text is lost.
The material design documentation states that it can be dismissed when the outside is touched but this doesn't work for me.
I want to intercept the onOutsideClick event and check the keyboard's state:
Keyboard shown: Close the soft keyboard
Keyboard hidden: Dismiss the Bottom Sheet
Should I use a custom BottomSheetBehavior or can I Override some dialog methods?
Related
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
Initially the bottom sheet is remains hidden, when I click on some place then bottom sheet should appear and when I click clear icon then the bottom sheet should be hidden actual manner, which is should be on initial state.
Initial App launch code:
bottomSheetInfoBehavior.setHideable(true);
bottomSheetInfoBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
After clicking on some place then this is the code which pops up the bottom sheet:
bottomSheetInfoBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
Finally when the clear icon is clicked then this the code that is hiding the bottom sheet (NOT WORKING):
bottomSheetInfoBehavior.setHideable(true);
bottomSheetInfoBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
Expected Result is:
When the clear icon is clicked then the bottom sheet should not appear in the screen, that should be disabled..! and should not visible in screen..!
You should use Bottom sheet's dismiss method in clear button.
And
use show method to show the BottomSheet dialog.
Keep the reference of BottomSheetDialog and use is accordingly.
From the code you have shared u are setting the state/behaviour of the BottomSheet which will be taken care by these method's automatically.
Ref:
BottomSheetDialog
I have a custom QuickAction menu in my app. I have added contentDescription "Open Menu" for the ImageView which opens the menu. So my TalkBack(form the Accessibility settings) announces the same. The popup menu has setOutsideTouchable(true) to dismiss it when touched outside. When TalkBack is On user has to double tap to dismiss it but Android does not announce any such message. Ideally, it should announce "Double tap to dismiss ...". How can I achieve this ? Also, I would like to announce when the menu is dismissed. I have tried sending AccessibilityEvent inside:QuickAction.setOnDismissListener(new myQuickAction.OnDismissListener() {
#Override
public void onDismiss() {
// tried sending event here
} Added reference image to explain in detail. On clicking button blue popup is the QuickAction popup. Now I want to announce "Dismiss Menu" when user tap anywhere(black dot) on white region. White region is actually my LinearLayout containing header, footer etc.(that are not shown in the image). I have tried adding the contentDescription, importantForAccessibility for the layout but to no avail.
I would add either a little "X" box, or if you don't want to mess up your UI, make your layout container focusable, and add the content-description "Double Tap to Dismiss". (Note: The double tap is a talkback gesture, don't add this, just replicating from your question.)
EDIT: Essentially, what I'm recommending, is instead of adding an "X" button to the view, allow the layout view to act as an "X" button itself. By adding a contentDescription to the layout, you are making it focusable, even though typical users wouldn't interact with this view, nothing is keeping TalkBack users from doing so. Thus you do not change your layout visually, but still have the accessibility benefit of a separate close button, even though technically speaking this is not necessary, as users should understand how to close modals without it.
I don't believe announcing that it has been dismissed is necessary. Shifting focus back to the element that was focused before you opened the modal is the typical approach. Have this happen after your double tap, and TalkBack users will know the menu was dismissed, because they are back in the main view, on the element that opened the modal.
Sidenote: Ensure your QuickAction behaves as a modal!
In my Android app, I'd like to slide a custom view up from the bottom of the screen while the keyboard is onscreen, either overlaying the keyboard or temporarily animating it out of the way. Ideally the view would be the same size as the keyboard. The user would briefly reference with the custom view, then tap to dismiss it, bringing back the keyboard.
How would I go about doing this? Thanks.
I'm using the v16 API and having problems with where the popup is being placed when the onscreen keyboard is displayed.
The first problem is that if the EditText is at the bottom of the screen, when I touch the field to open it for editing the popup is displayed below the control and the immediately covered as the keyboard appears. It doesn't reposition itself above the EditText until a keypress triggers my validation code to fire again on the new value.
The second problem is that when I close the keyboard and the ScrollView containing the text scrolls back down from where it positioned itself to show the EditText above the keyboard the popup remains placed on the upper half of the screen instead of where the EditText is until I touch something else on the screen (triggering the ScrollView to do a redraw???).
Unfortunately that popup has various problems like this :(
Perhaps a simple solution in your case is to forcibly invalidate the UI when the keyboard has displayed and dismissed? Can't recall if the Popup will reposition if the EditText is invalidated, but worth trying as the alternative may be to re-implement.
Checkout my android-formidable-validation lib on github, it re-implements...though has its own problems - if you go down that path, why not give me a hand with some contributions ;)