I have a Floating Action Button with a custom menu of mini Floating Action Buttons, that appears upon click on the main Floating Action Button.
The mini FABs are in a LinearLayout.
I want that after opening the FAB menu, when the user clicks elsewhere, the menu disappears. However, I haven't been able to find how to do this.
What listener do I need for this?
Any help?
Thanks.
You are most likely interested in a custom FloatingActionButton.Behavior:
https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.Behavior.html
https://medium.com/#nullthemall/floatingactionmenu-floatingactionbutton-behavior-dd33cc0d9ba7#.jsvuvz2rk
Otherwise you can simply set the Visibility of the respective controls to Gone based on a OnTouchListener that checks if you are touching outside the FAB.
Related
I am currently working on a calculator application which has a scaleable NumPad with a lot of buttons:
The Buttons on the NumPad should register user input when they are clicked. Additionally, if the user performs a zoom-gesture on the NumPad it should increase in size / decrease in size.
What's my Problem?
I want to handle onClick events if the user taps a button, but also handle a gesture if the user pinch-zooms on the buttons. How can I do that?
GitHub Repo: https://github.com/Max-We/TheCalculator
Hi #FxMx you can have a look at this - Pinch Zoom and onClickListener for same layout not working in Android
You can set a ontouchlistener on your NumPad layout and do nothing if its single touch and you can set onClick listeners to your NumPad buttons which can perform your register events.
Best description for my issue was at
Keyboard layout hiding android action bar?
And I will paste-quote here:
"I have this problem also but the difference is, i have a list above my edittext and can't use a scrolling container. If I use adjustResize when the edittext is focused it appears above the list and the last items from the list get obscured (list is not pushed up). If I don't use adjustResize on the other hand, when the edittext is focused it pushes everything up but the acionbar is hidden and also I cannot scroll to the top of the list. Can someone share a solution for this? "
So
I have a toolbar
then a chat content
and then a bottom bar for sending a message (editText and a button)
Now, when I tap on an ediText, and soft keyb opens up, I do NOT want my toolbar to collapse and hide, but I do want my chat content to scroll up, so above the bottom entry I will see the last messages from chat content (in listView).
I've tried a number of combinations for Activity adjustResize or adjustPan, but none of them was working. Even wrapped toolbar in CoordinatorLayout and AppBarLayout, but still, no results. Either my content gets pushed/scrolled correctly but toolbar hides OR toolbar stays but softKeyboard overlaps last couple of messages.
The solution I share is a workaround. I had implemented a function scroll(), to scroll my content if a new message arrives, so that was one function I implemented before. I was missing the other part and that is, detect when a softKeyboard was open so I can scroll my content.
That was easy to find here on
How to check visibility of software keyboard in Android?
I hope someone will find this workaround useful and sleep at least a couple more hours.
Note:
Animation of sliding content up is not consistent with softKeyboard sliding up. After keyboard is opened, then I do scroll, which is not in-sync. It is just a snap. But I don't care about that until I find a better solution for orchestrating this event using a native Android component or layout.
The easiest and best solution to all of the above is to simply use the following:
listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
In my application (only for my application), I want to add a button to the navigation system bar
How I can do that in my code?
You cannot do anything there. Not to mention some devices will not show this bar at all if they got hardware buttons.
You can't.
Maybe try to add a fragment that will be exactly above it.
Some phones don't even have that buttons on screen.
firstly check mobile or tab has soft buttons if has then make full screen by programaticaly after that create custum button bar like tab bar at bottom and put buttons as you like thats better if u dont have any other idea
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
I have an app with a normal menu i.e. the common old menu that shows up at the bottom of the screen when the menu button is pressed. But it is a problem in some phones where there is no hard menu button.
I want to switch to slider menu with a menu icon on top. Is there an easy way to do this (I mean a way where code change would be minimum) retaining the existing functionality? Or will i have to go about coding the slider menu from scratch?
Any example code of a similar situation would really help.
I have an app with a normal menu i.e. the common old menu that shows up at the bottom of the screen when the menu button is pressed
Normally, that "menu" will appear as the overflow on devices with an action bar that either:
do not have a MENU button, or
run Android 4.4+
But it is a problem in some phones where there is no hard menu button.
Make sure that your app has an action bar.
I want to switch to slider menu with a menu icon on top
The options menu/action-bar-with-overflow is unrelated to the "slider menu". They serve different roles. Please read the design guidelines for a navigation drawer (a.k.a., "slider menu").
Is there an easy way to do this (I mean a way where code change would be minimum) retaining the existing functionality?
No, because they are not related.
I create an app which need to disable all buttons to allow user to leave the application - back button, menu button, camera button, call button, etc, and app should have 1 button for exit. I don't know how to disable all buttons. Tell me please, thank you
The Physical buttons? No, you can't disable all of them. Home button needs to work... Android - Is It possible to disable the click of home button
Related: Android: mass enable/disable buttons
Try this: when you enter the activity, call
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
and when you exit the activity, call
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION);