This question already has an answer here:
Android: Using default styles
(1 answer)
Closed 8 years ago.
Okay this is the third time I am asking this question. It would be appreciative if someone gave me a concrete answer with an appropriate example..
While styling my Android UI, I needed to change the look and feel of my ALertDialog. However, I tried import the alert dialog default style using the following
style name="alertDialogStyle" parent="#android:style/AlertDialog"
While doing the above I get an error saying something like "parent resource not found". As far as I heard from others it seems that its a private style and cannot be used.
So is there anyway that it can be used that I am nit aware of?
I think you are supposed to use a Theme as your parent instead of a Style.
For AlertDialog, the default theme is #android:style/Theme.Holo.Dialog.Alert for Honeycomb and later, and #android:style/Theme.Dialog.Alert for older versions.
You can see the theme declaration in [ANDROID_SDK]/platforms/android-19/data/res/values/themes.xml. There are several variations you might be interested into.
Related
This question already has answers here:
android.view.View.systemUiVisibility deprecated. What is the replacement?
(21 answers)
Closed 2 years ago.
Recently Google has deprecated setting system UI visibility directly using the setSystemUIVisibility method found in the View class and passing flags to it.
I couldn't find the source code for this as it's not released publically yet. Do you guys know how I can achieve going fullscreen without using this method?
Yes now since it is deprecated, you can use:
window.setDecorFitsSystemWindows(false)
Then make sure you make the status bar transparent as well by adding below style to your app theme
<item name="android:navigationBarColor">#android:color/transparent</item>
Hope this helps :)
This question already has answers here:
Android changing Floating Action Button color
(26 answers)
Closed 6 years ago.
I am novice for the android world. Just for improving my skills, I am learning android. So I am creating a social app there I have used floating action button, on which if user clicks it increases the number of likes.
By default, floating button is taking accent color but I want to use different color. I tried a lot but not getting any solution. Yes, there are so many libraries available that I can use to achieve my goal, but I do not want to use any external library. I believe to use core methods of android.
Is it like, there is no solution except using external libraries? I tried this one, but xml file is throwing error when I am using app tag.
If you wish to change the color
in XML with attribute app:backgroundTint
in code with .setBackgroundTintList
I am using this library:
com.android.support:design:23.1.1
Please comment on the same. I know for Android guru's this is not big deal. I know this question has been already but I didn't get solution for my problem. That's why I am opening this question again.
As described in the documentation, by default it takes the color set in styles.xml attribute colorAccent.
The background color of this view defaults to the your theme's colorAccent. If you wish to change this at runtime then you can do so via setBackgroundTintList(ColorStateList).
If you wish to change the color
In XML with attribute app:backgroundTint
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
...
app:backgroundTint="#color/orange"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal" />
in code use setBackgroundTintList
This question already has answers here:
Style SnackBar in theme app
(5 answers)
Closed 2 years ago.
I would like to reduce boilerplate setting up Snackbar colors in my code. Can I style it overriding an existing style, for example?
Unfortunately, Snackbar using a few common items with other widgets (like colorAccent), so just changing those was problematic for me too. Instead I added my own design_layout_snackbar_include.xml. Take the original and modify what you will need. It will work for all of your snackbars.
I am curious to know if there is anyway I can remove OR change the drop-shadow like effect that android gives below a Tab layout.
As soon as I ask this question, I get the answer in another stackoverflow post. Anyways for the benefit of people who have landed on this post, the answer is to
use a custom theme with its windowContentOverlay set to null
I am writing my little Android app. I pop up a dialog control which is a nice, non-fullscreen, rounded-corners dialog by setting android:theme="#android:style/Theme.Dialog" on the activity in my manifest. That all works just as I expected. However it is just a drab, grey-titled dialog as in this screenshot:
I've noticed however that a LOT of applications, when they pop up dialogs have a nice, blue-themed title as in this screen shot.
I would assume this theme is some common theme, as it shows up in a LOT of different apps. I would assume it is something built in to the OS. (My phone is a Captivate with the official Froyo release). Of course it COULD be something that every developer simply re-coded on their own, but I doubt that.
Assuming that this is a common theme, how do I utilize it in my app? What changes do I need to make to my activity to have it use that theme?
Thanks in advance!
You can set your activity to use a default theme like Theme.Black. There are default themes and they are in R.style - although i'm not sure which are available to which platforms(i.e. i think the holo themes are for 3.0 and up...
http://developer.android.com/reference/android/R.style.html
see here http://developer.android.com/guide/topics/ui/themes.html for defining your own custom themes and scroll all the way down for using the "platform styles" and themes.
Rather messy (there doesn't seem to be a good reference for this), but the platform styles are defined in \platforms\android-\data\res\values\styles.xml and \platforms\android-\data\res\values\themes.xml. You can dig through those and figure out the theme/style IDs that are available at compile time.
Other than that its really just trial and error.
To make a dialog you need to extend the dialog class. And to have a nice title bar you can use:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
and have your own custom title.
to have a title use:
setTitle("MyTitle");
You can also assign your custom view for the title.