I am opening a dialog fragment on Button click in a activity. Now I don't want loose focus on my background activity after opening the dialog fragment. The background activity has a chat window so the edit text in that chat window should not loose focus, to be more precise one should be able to chat even when the dialog fragment is open. Is there any way to make this happen?
One can place an individual layout( which is your dialog layout ) onto the center of the screen
(gravity="center" or centerinParent="true")
and set its visibility to invisible or gone.Then when you make the dialog layout appear, the edittext will be focusable as well.
I would encourage other answers which may be an alternative to this behavior which the OP wants.
Related
I have a custom Spinner class and which uses an alert Dialog to display its contents and it has "Submit" and "Cancel" buttons. The alert dialog has one edit text and others are just read-only labels. On click of edit text the virtual keyboard appears and it moves the layout moves bit up but the buttons remain hidden. I want the buttons to be visible also.
Things I have tried so far:-
Manifest :-
android:windowSoftInputMode="stateVisible|adjustResize"
android:windowSoftInputMode="adjustPan"
In Activity Class:-
this.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
It is just moving screen enough not to hide the edit text where as my button are still remain invisible.
You can't. The height of the keyboard is decided by the keyboard- it can't be made smaller. The rules for the keyboard are that if it the cursor would be covered, unless all movement is shut off it will scroll everything the minimum such that the cursor is on screen. There is no way to tell the OS to scroll it more than that. There is resize, but I'm not sure that will work for an alert dialog- I think those still go full screen. The keyboard API just isn't made for your usecase.
I'm trying to display an activity with a button that covers a portion of the screen similar to a dialog.
This was almost working as I wanted it by using #android:style/android:Theme.Holo.Panel. It wasn't quite what I wanted however as I want the background to be dimmed with the activity is displayed. So I switched to this style instead: #android:style/android:Theme.Holo.Dialog.NoActionBar.
Now this looks like I want it and the background is dimmed. BUT the problem with this is if the user touches anywhere on the screen apart from the dialog then the activity gets dismissed. This does't happen with the Panel theme, the user can only dismiss it by pressing on the button.
How can I prevent the activity from being dismissed on any touch event with the Theme.Holo.Dialog?
Have you tried this.setFinishOnTouchOutside(false); ?
This being your activity.
I know this should not be a big challenge but it really drives me insane.
I am developing a simple soft keyboard input method and basically I have added a button to my softkeyboard, by pressing which, a dialog should pop up to prompt user to do some choices.
By far everything is ok about creating and opening the dialog. Since normally a dialog is created and displayed from outside an activity, so a flick solution could be to create a transparent activity which embedded the dialog in it. By doing so, I could easily start a dialog when user click the button on my softkeyboard.
But one tricky problem is: every time user click the button and the dialog (actually a dialog in a transparent activity) displays, it will always make my softkeyboard hide. I just need to start the dialog without any changes to the status of my softkeyboard -- I want my softkeyboard keeps showing when the dialog starts.
Here is a snapshot of Google Keyboard, it has the similar button which display a dialog and the dialog did not hide the keyboard, this is exactly what I want. So please anyone suggest me how to achieve this. Thanks so much.
THey aren't launching an Activity. They're launching a dialog. Which is tricky from an input method because its a service (you have to specify the dialog's window token to make it show) but doable.
In an android application, I want to display a Dialog on screen and in the same time to allow user to click on the application's UI when the the Dialog is open
can this be done?
if no, what can I use instead of Dialog?
I don't think you can do this with Dialog. But you can do it with PopupWindow using PopupWindow.setOutsideTouchable(true);.
Showing up a dialog over your Activity, will make your Activity go into onPause() so you won't be able to actually handle things inside that activity anymore until the dialog is dismissed.
If you want to have some view, overlay your original activities view you'll be looking for into the direction of FrameViews, which can overlap other Views.
I am using a dialog themed activity in android to show a popup from a application context. The dialog has a transparent theme, but the issue is that I want the underlying activity to have focus and not the popup though the popup must be visble. How do I achieve this in android?
I think you would have to use a Fragment and just make it look like a popup dialog.
You can not switch focus between activities. There's only one activity "on focus" at the time, and is the one that is being displayed at that point. The transparent background doesn't mean you can access the activity below.
If i don't get it wrong, you want to be able to interact with the activity's controls while having a "Dialog" on the screen. Any sort of Dialog class from Android will not help, since they take the focus away. Not really sure about PopupWindow, but i'm guessing will be the same thing as the documentation says "that appears on top of the current activity."
You are going to have to create a custom dialog using a RelativeLayout/FrameLayout within your activity.