I modified my theme using the following style (part):
<item name="android:scrollbarTrackVertical">#drawable/scrollbar_1</item>
<item name="android:scrollbarThumbVertical">#drawable/scrollbar_2</item>
(plus of course drawable definition).
However it only works with activity. When activity opens dialog (DialogFragment), scrollbars are standard ones, not mine. Why?
Any help?
Related
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
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.
In 4.x devices, the drawable which indicates that this is a spinner and should be clicked is barely visible; it is using spinner_ab_default_holo_light.9.png. How can I make it use spinner_ab_default_holo_dark.9.png, or any other drawable of my choice?
The spinner is in a dialog. The app uses ActionbarSherlock 4.3.1 for Android 2.2.3 upwards compatibility. The app implements Android Action Bar Style Generator to create a Sherlock.Light.DarkActionBar theme. I am using a Values and a Values-v14 to manage the styles. This dialog attaches a specific style:
new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.FibroDialog))
which, in Values-v14, has a parent theme to make sure the dialog background is dark:
<style name="FibroDialog" parent="#android:style/Theme.Holo.Dialog">
</style>
Things I have tried:
In the theme generated by Android Action Bar Style Generator I added
<item name="android:spinnerItemStyle">#style/MySpinnerItemStyle</item>
and then added
<style name="MySpinnerItemStyle" parent="android:TextAppearance.Holo.Widget.TextView.SpinnerItem">
<item name="android:textColor">#FFF</item>
<item name="android:background">#drawable/spinner_background_ab_fibromapp</item>
</style>
which resulted in the drawable I actually want becoming the background of the item, not the spinner.
In the xml for the spinner, I tried
android:dropDownSelector="#drawable/spinner_ab_default_fibromapp"
which gives the same result as above, and
android:popupBackground="#drawable/spinner_ab_default_fibromapp"
which replaces the background of each spinner item with the drawable.
As a last resort, I made my own spinner_ab_default_holo_dark and spinner_ab_default_holo_light 9-patches; and they didn't show up at all.
How can I access that spinner drawable and change it to whatever graphic I want?
Although i'm new at this, i've also spent far too many hours looking for a similar answer. It seems the only solution is to create a style which is an exact copy of the system's spinner style and edit that which you which to change. It's troublesome, boring and not really practical, but if it must be done, it must be done... Due to time constraints, I ended up changing my layout a bit so that the standard spinner wouldn't look too bad.
I am attempting to style a DialogFragment and, despite extensive research within SO, developer.android and elsewhere, it's just not working right.
I am sure that I have applied everything correctly; in my DialogFragment onCreateDialog, I am putting:
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.FibroDialog));
and in values/styles.xml, I have:
<style name="FibroDialog" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#drawable/panel_background</item>
</style>
and in values-v14/styles.xml, I have:
<style name="FibroDialog" parent="#android:style/Theme.Holo.Dialog">
<item name="android:windowBackground">#drawable/panel_background</item>
</style>
If I run that, I get the top row of dialogs in the image below, where nothing has changed at all, but I would expect the window to use my panel_background drawable. If I change windowBackground to background, I get the bottom row of dialogs in the image below, where it all goes wrong.
So how do I change this, so the entire dialogs have the purple background? I know I can use the layoutInflator and put a background colour in the layout, but that only does the middle bit.
I don't know if this is of any relevance, but the DialogFragment is launched from a SherlockFragment
(Note: build minimum and target API 7)
Ok, here is a real stumper for this newbie between the chair and the keyboard:
I am applying a them to my app, and using AlertDialog for some key information at a few key places (i.e. a EULA pop up on first app run). My problem is this, everything is fine until I apply a theme (or style to the Activity). My text everywhere but the pop ups formats correctly. The problem is that I am changing from the default white text on black back ground to black text on white background. The background changes on the pop ups but not the text, so the net effect is that I have a white pop up with the text there (scroll bars show for the long winded EULA) but the text is unreadable because it is the exact same color as the background.
Here is the my_style.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="main">
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#000000</item>
<item name="android:typeface">sans</item>
</style>
</resources>
I know I am implementing the call correctly because everything else in the app formats correctly, what am I missing? The app works just fine when the android:theme="#style/main" is removed from the <application> tag in the manifest file (formating removed from the entire app and the dialogs are readable). Thanks for getting a newbie set straight.
Have you passed the theme to AlertDialog's or AlertDialog.Builder's constructor when creating the dialog?
See here.