All of the Android material icons come in either black or white:
https://www.google.com/design/icons/index.html
Which I add to my layout like:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_plus" />
Is there a way to change the color of the icon from black/white to something else in the layout/code?
I've heard of the android:backgroundTint="#color/green" property, but does this work across all versions of Android? For example, if I use this property in my layout, will it change the color on Android versions older than 5.0?
Edit: Wow, you guys are good at making a new user feel unwelcome.
I think, It is not possible to all android versions.
you can design icon color in this website.()
Note: Google Designs icons also available in this website.
Icon generators allow you to quickly and easily generate icons from existing source images, clipart, or text.
http://romannurik.github.io/AndroidAssetStudio/
Related
I am using CardView as custom item for RecyclerView. They looks good on Android 5+ but so different on older Android versions.
On Android 5 +
On Android < 5
The code is the same:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="1dp">
... other items ...
</android.support.v7.widget.CardView>
Is there a way to achieve the Android 5+ behavior on pre-Lollipop devices?
Using the support CardView? No.
Personally I think that the support CardView is broken and shouldn't be used at all. It looks and works a little bit different on Lollipop and on older systems. The shadow is different, the padding is different, content clipping doesn't work on pre-Lollipop devices, etc. The API is also weird and confusing. That's why it's hard to get good results on all platforms. If you can live without cards, I would go that way.
Of course it's possible to create a custom, nice-looking, backwards-compatible card, but it's a bit complex task. To create a card on your own you have to implement:
rounded corners with content clipping (doesn't work in the support CardView). Here's how to do it properly.
shadows drawn outside the card (not inside, like the support CardView). This one depends on your needs. I would override drawChild(...) in a parent container, where I could draw shadows around cards freely. Shadow generation method doesn't matter - it could be a gradient, a static 9-patch or a RenderScript-blurred black shape.
I was frustrated by the look and the API of CardView as well, so I created my own implementation. It can be found on GitHub - the library is called Carbon and using it is probably the easiest way to get a decent card. After importing the library simply add style="?attr/carbon_cardViewStyle" to any layout to make it look like a card:
<carbon.widget.RelativeLayout
style="?attr/carbon_cardViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
I have an android app that has been working fine pre-Android 5.0. With the update, I noticed that checkboxes and radiobuttons placed on white backgrounds are not visible if they are not selected. For example, this is what a checkbox looks selected and unselected in jellybean:
As you can see, there is a light gray square when the checkbox is not selected. However, after updating to lollipop, this is what it looks like:
So, as you can see, there is no gray square or anything that suggests there is a checkbox here. The same problem happens with radiobuttons. I really don't want to go trough the pain of creating new drawables just for this simple ting. I have seen that checkboxes within the accessibility menu of android 5 have a nice square, but haven't figured out how to make mine look the same:
I tried creating a new android project and just adding some checkboxes and radio buttons with a white background, but they are still invisible when unchecked. I'm using xamarin studio and c#, if that makes any difference. Anyway, I'll understand any java code you post.
This is what my checkbox code looks like:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/chkSeleccionar"
android:layout_gravity="right"
android:gravity="center_vertical"
android:clickable="false"
android:focusable="false"
android:scaleX="1.5"
android:scaleY="1.3"
android:layout_weight="50"
/>
I couldn't get the theme working, but what did work for me was the following:
android:button="#drawable/abc_btn_check_material"
android:buttonTint="#color/red"
Put this into your CheckBox XML layout.
Just change the
android:buttonTint="YOUR COLOR"
It works.
Make sure you are using a Material theme for Android 5.0 devices - this will ensure you're styling remains consistent with other components. Look for an android:theme element in your AndroidManifest.xml file (either on your application or on an individual activity), then look up what style is set there and check the parent attribute for the style.
Add this attribute
android:buttonTint="#EEEEEE"
I have a simple DialogFragment which shows a bit of text (which contains a Year string) and then a SeekBar that the user can slide and change the Year string.
On Android 3 and 4 this looks right... those platforms have a light background and use black text.
However, on Android 2, the dialog has a dark background and is still using black text.
I don't want to have to configure different color schemes for different versions of Android because there has GOT to be some default values built into the Android system that I should be able to use to style my TextView so that it uses the appropriate text color.
Here is my TextView that displays the year string:
<TextView
android:id="#+id/textViewYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="1976"
android:textAppearance="?android:attr/textAppearanceLarge" />
What settings can I apply to my TextView so that it will always be appropriately colored by the system?
Note, I can't just use an Inverse style, because on Android 3 and 4 it is working properly. If I use an Inverse text appearance then it works on Android 2, but fails on 3 and 4.
I found the solution on another SO post:
builder.setInverseBackgroundForced(true)
On Android 3.x and 4.x this doesn't seem to change anything, but on Android 2.x it inverts the color scheme so that the background is white so the black text shows up properly.
I have created an Editbox in XML using this code:
<EditText
android:id="#+id/txtEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:inputType="textEmailAddress" >
</EditText>
The textbox renders like this:
How can I get the native android EditText with the orange borders when focused, white background etc. ?
I tried adding
android:background="#android:color/white"
but that only changes the background to white.
The style you are seeing is "native" for the Honeycomb (3.0) Android version, specifically, the new Holo-dark theme. The orange-borders-and-white-background look was last used in 2.3.* and has since been left behind.
Agree with the answer of neutrino: The style you are seeing is "native" for the Honeycomb (3.0) Android version, specifically, the new Holo-dark theme.
But still if you wants the EditText that you want then you need to set the style/theme inside the AndroidManifest.xml file:
<activity android:theme="#android:style/Theme.Light">
when we add view's from layout, it renders from framework, then add the properties we provided . so in your code, EditText is native EditText, which varies from device to device . so if you want look and feel over a particular device make your own style for that and use it .
Had the same problem...
Try using:
EditText usr=(EditText)findViewById(R.id.editText1);
usr.setBackgroundResource(17301528);
If you really want to older versions of the EditText iamges (from sdk/android-8/platforms/data/res folder), place thema in the drawable folder, create a StateListDrawable out of it, and set the background of the EditText as that Drawable. But why bother ? Let app users enjoy the default look and feel of their device.
The default progress wheel on Android doesn't display well when the background is white, it's barely visible. How can I fix this?
If you look at the built in styles.xml file and poke around the platform's built in drawables, it turns out the solution is pretty simple. You can use the "style" attribute to use the inverse progress bar:
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="40dip"
android:layout_height="40dip"
android:padding="6dp"
android:indeterminate="true"
style="?android:attr/progressBarStyleInverse"
/>
Be sure if you have a white background to set the theme in your manifest to #android:style/Theme.Light. This provides resources for all of the widgets to go with a light background.
I dont think there is way to fix this since the progressbar is sdk dependant. orange on 1.5, white on 1.6 etc... green on some devices, etc etc...
Your would have to implement/override it with your own graphics to change it.
I had the similar problem, i solved it by setting a constrasting background on the progressbar. (50% transparent black)
Here is similar issue using the horisontal progressbar implementing a custom color:
How to change progress bar's progress color in Android
The circular is abit diffrent i think, but probably not impossible ;-)