Android Dialogue Fragment not moving up when keyboard is visible - android

I have implemented a custom dialogue fragment which contains a custom view pager and an edittext.View pager contains a grid. To move the view upwards when keyboard is visible I have placed the view inside a scrollview. When app is running view pager is not displaying. How can I make this custom fragment scrollable when keypad is visible. Please help me. Thanks in advance.

Add android:windowSoftInputMode="adjustPan" to the corresponding activity tag in your application manifest file.

In my case I tried everything, however the problem was not in the implementation of the dialog, or how the keyboard was invoked. I was using a theme to make the status bar translucent and that caused the wrong behavior, by changing to another theme the dialog goes up without problems when invoking the keyboard. I hope my answer is helpful
I was using this style
<style name="TranslucentTheme" parent="MyTheme">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:fitsSystemWindows">true</item>
</style>

Related

Changing default Android fade/scrim color when calling a Dialog

I've been working on an app and I've reaching the point where it requires me to display a menu window in the middle of the screen.
I've been using an AlertDialog object filled with a custom View but now it was required of me to "surround" the window with a semi-transparent white glow as opposed to the default grayish one. I did a similar with the fade-in color of some navigation drawers I have on my app but in that case I had a specific method to quickly help me solve that problem. So far I haven't found anything that helps me solve this one.
I tried creating a default style with a new "windowBackground" value but I encountered 3 problems from the get-go:
I'm no longer able to shut the AlertDialog down by clicking outside the layout (I'm guessing because by changing the color that way everything is now the layout)
The menu window is now surrounded by a black outline that wasn't there before
By using the filtering search inside the layout, which manipulates the members of a list, the window collapses on itself
Is there any way to accomplish what I want more or less directly?
I'm not really sure about it, but you can use this in your styles.xml
<style name="MyDialogTheme" parent="android:Theme.AppCompat.Light.Dialog">
<item name="android:windowFrame">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/your_light_color</item>
<item name="android:backgroundDimEnabled">false</item>
And if you want to dismiss the dialog when clicking outside, use this:
dialog.setCanceledOnTouchOutside(true);
or
<item name="windowCloseOnTouchOutside">true</item>
in your styles.xml

windowSoftInputMode has no effect in Android M

I have a MainActivity with android:windowSoftInputMode="adjustNothing" set in the AndroidManifest. The Theme has parent Theme.AppCompat.Light.NoActionBar. I add a DialogFragment to this activity and show an AlertDialog inside of it, then set alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); inside the fragment.
Now, on Android 5.1.1 it works as expected. The keyboard does not auto show when the dialog is created. When the user taps on an EditText inside of the dialog, the keyboard pops up and resizes the activity so that it won't overlap.
The problem is that on Android M, this doesn't happen. The keyboard is indeed not shown when the dialog is created, but when it pops-up after the user touched an EditText, it overlaps the dialog.
Any idea why this happens on M, but on previous versions everything works fine?
Edit: Apparently after creating a HelloWorld project with only the basics of the issue, I've found out that the below 2 Activity Theme elements cause the keyboard to not resize. If anybody has any permanent solution to this matter, I'm all ears (or rather eyes).
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
I've figured out that the following 2 lines from the Activity Theme causes the keyboard to not resize.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
For now, this is a quick fix. If anybody has a permanent solution to maybe retain those 2 lines but also fix the problem, please do post another answer.

Android soft keyboard keeps pushing action bar off the screen

I got a fragment which is contained inside a PageViewer which is inside a TabHost inside an activity. The fragment contains only a linear layout with a list view and under it an edit text. I have added a border around the edit text by using an xml of a rectangle shape and adding it as a background.
The activity itself is declared like this:
<activity
android:name=".MyAcivity"
android:label="#string/app_name"
android:theme="#style/CustomActivityTheme"
android:windowSoftInputMode="adjustPan">
</activity>
The theme:
<style name="CustomActivityTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextColor">#color/blue</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
When pressing the edit text, the soft keyboard is appearing and it's hiding both the action bar and the tab host. It's also hiding the bottom part of the border around the edit text.
I have already tried switching from adjustPan to adjustResize but adjustResize got no effect at all on the layout and is acting the same as if I didn't declare it at all.
What can be done?
I eventually didn't even need the WindowSoftMode property. What confused me was the fact that the EditText was getting smaller when I pressed it and the soft keyboard was shown. Inside the fragment I had a list which had a height weight of 0.9. When I changed it to 0.85 it was fixed. I guess it was too much for edit text to handle when the keyboard was shown.

Customize dropdown dialog items in WebView

I am including a WebView into an Android View. In the page loaded in the WebView I have a drop down. When I click on the drop down, a dialog appears (it is the native Android dialog) but it has a bad look.
I would like to change those styles.
It seems to me that I need to change a theme style in the xml but I don't know which property could affect the webView dialog.
<item name="android:dropDownListViewStyle">#style/DropDownListView.App</item>
<item name="dropDownListViewStyle">#style/DropDownListView.App</item>
<style name="DropDownListView.App" parent="#style/Widget.Sherlock.ListView.DropDown">
<item name="android:listSelector">#drawable/list_selector_holo_light</item>
<item name="android:divider">#drawable/abs__list_divider_holo_light</item>
</style>
I have tried to change this property but nothing happened.
What property should I change to modify dialog list style?
Thanks

Android - Remove/Add padding between buttons on AtionBarCompat

I am using the ActionBar Compatibility, everything is OK, except the fact that by default, the buttons (actions) have some padding around.
How can I alter that padding for specific buttons, remove it, and in some cases adjust.
I managed to resolve this issue by creating a custom layout and attaching it to the ActionBar, by configuring the styles:
<style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showCustom</item>
<item name="android:customNavigationLayout">#layout/actionbar_custom_title</item>
</style>
Now there appeared another problem: Please see this thread if you can help me: Android - Remove "More actions" button from the ActionBar

Categories

Resources