Android :: Turn A Color Drawable Into A Grayscale One (to Indicate Disabled State)?
Nov 24, 2009What would be the right way to turn a color Drawable into a grayscale one (to indicate disabled state)?
View 3 RepliesWhat would be the right way to turn a color Drawable into a grayscale one (to indicate disabled state)?
View 3 RepliesI've seen this code on the web...
My questions are:
1. Is 'bmp' supposed to be the color bitmap I want to affect?
2. How do I get the 0-255 value of the grayscale?
I am using a <Button> widget in one of my layout. I created this button in disabled state. A thin white line runs through the button, at center horizontal, while it is in disabled state. And in enabled state it is normal like any other widgets.
Below is the layout code:
CODE:....................
To give the user of my app an indication which field currently has the focus I am trying to change the background color of some of my fields depending on the current state, however, I am having troubles understanding Androids Color State List Resources:
There is this example at the bottom of http://developer.android.com/guide/topics/resources/color-list-resource.html. If I try exactly the same, i.e. if I want to adapt the textColor , things do work. However, if I try an only slightly different thing, namely to adapt the background color, things do not work and I don't understand why? Why is this so inconsistent?
To make it simpler to understand what I am trying to do, I append my misc. .xml files:
The AndroidManifest.xml file:
CODE:.........
If I run this as shown here, it works, i.e. I get a button whose text color changes depending on whether the button is focuses, pressed, etc.
If I uncomment the lower button, where I just flipped the attribute values for textColor and background I get an exception, stating
... <item> tag requires a 'drawable' attribute or child tag defining a drawable
What the heck am I missing here? Why is that color state list acceptable as a text color but not as a background color? How does one specify a view's background color depending on the view's state?
I know how to put the icon on each tab, that is no problem. I also ran across this : Stack Overflow thread on pretty much same thing I followed one of the links from that question, and found this Pretty much, it said use a selector defined in the xml, sure, did that. But there is no id associated w/ it so I am not sure how to get the selector function as a drawable so I can use it as the icon for the tabs. Maybe I am going about this the wrong way.. But this is what I have, and obviously missing something.
View 4 Replies View RelatedI would like to vary the text color of a custom button that I am making depending on which state it is in (enabled, disabled, state pressed).
I know how to use an XML file to describe the different drawables that I need for the different states like so:
CODE:...........
How do I style the textColor when pressed and textColor when disabled states without resorting to a subclass of a Button?
This is some part of the colors.xml from android samples directory. Now my question is that, what is the difference between defining a color in <drawable> tag and <color> tag ?
View 1 Replies View RelatedOn the android website, there is a section about color drawables. Defining these drawables in xml looks like this:
<resources>
<drawable name="solid_red">#f00</drawable>
<drawable name="solid_blue">#0000ff</drawable>
<drawable name="solid_green">#f0f0</drawable>
</resources>
In the java api, they have thr following method to define rounded corners:
setCornerRadius(float radius)
Is there a way to set the rounded corners in the xml?
I want to buttons of different colors, but I want to do so while using the default button background resource in order to preserve the onfocus and onclick states. This is because I want to use the default highlight color of the OS for my app, which is NOT always orange (HTC Sense makes it green).I found that adding a color filter to the button's background drawable works great (in this case, blue).
View 3 Replies View RelatedJust wanted to relay my issues that occurred with Startup Auditor. I use a Moto Droid 2.0.1.
First issue: I disabled Google Talk Startup as non of my friends have an Android device. This caused an issue with the Market. none of my apps would download the updates and I could not Download new apps. The Market is somehow connected to Google Talk. After enabling Talk and logging back in my apps started downloading.
Second issue: I disabled the stock messaging app because I am using Handcent SMS. This caused my text messages to delete themselves. When I opened my messaging treads all that was shown was my side of the conversation. After re enabling the stock Messaging app my messages started downloading and showing up in the treads. Handcent must use some of the same things that the stock app uses and Startup Editor was killing.
I have a Droid RAZR MAXX running Android 4.1.2 and for some reason my phone just freezes overnight. When I wake up the notification light may or may not be blinking and when I try to press the power button to wake it from sleep the screen will stay off. I usually need to perform a hard reboot by pressing the power and volume down button. After that I turn it back on by holding the power button as usual and I will be greeted with most of my settings reset and all apps reverted to their previous state. For example: If I update the Play Store app the day before it will be reverted back as if it was never updated.
View 4 Replies View RelatedI want to change the background image of a button either into a resource drawable or a solid color.
findViewById(R.id.myView).setBackgroundResource( xyz == 0 ? R.drawable.myBackground :
instead of zero, i want some solid color...
I have a ListView with the fast scroll enabled. The background of the listview is white and the text is black. The box indicating the letter of the section is being scrolled at the moment is in black. Is it possible to customize that color and turn to white? If yes, how can I do that?
View 2 Replies View RelatedI am running my application in the emulator using a high density skin (like WVGA800). However the ressources in my application are loaded from the drawable- mdpi folder instead of drawable-hdpi ... what else should I do so that android use the correct folder ?
View 4 Replies View RelatedI am trying to grayscale bitmap as follows, But it is crashing as soon as I run this method.
The problem is in last line. How can I assign "int" to "Color"? Or are there any better ways?
CODE:................
I have a compound UI component built up from a ViewGroup containing a number of TextView, ImageView etc. components. Many of these have StateListDrawables as their images/backgrounds. Is there any way of making them select from this drawable based on the state of the parent ViewGroup rather than the component itself? Ideally I want to be able to change the visual state of all children of the ViewGroup (text colour, image etc) based on the state of the ViewGroup, preferably without having to hook up complex logical code. This seems like a fairly common sort of requirement, so I was hoping it would be straightforward in Android - am I going to be disappointed?
View 1 Replies View RelatedI would like to convert a Bitmap to a grayscale array of bytes (one byte per pixel). At the same time I want to just crop at section from the middle. Having looked though the various api's it is not clear to me what the best way would be.
1) What is ALPHA_8? is that grayscale? I have a feeling that the grayscale effect should be done via some "saturation" on the paint object, right?
2) once I have the Bitmap in grayscale and the right size, what is the best way to get that to a byte[] of pixels (one byte per pixel)?
I am new to this site, and I come with a question about Android.
Is there any way to convert a Bitmap to grayscale? I know how to draw a grayscale bitmap (using canvas operations: http://www.mail-archive.com/android-developers@googlegroups.com/msg38890.html) but I really need The actual bitmap in gray colors (or at least something that could be converted to a bitmap later on).
Do I have to implement it by hand (pixel by pixel operations)?
I've searched a lot, and still could not find. Anyone knows a easy/efficient way to do it?
I'm a little confused by what I'm seeing with regards to phone state transitions via the PhoneStateListener. When I receive a call, this is what happens: (call comes in) RINGING -> IDLE (I pick up) OFFHOOK (I hang up) IDLE It's that first transition from RINGING to IDLE without any interaction from me (not ending the call, not answering the call) that confuses me. Do I really have to implement an idle counter to know that an incoming call has really ended? Seems like the reported phone state represents some sort of phone state that isn't the obvious one.Is this a bug or am I just not in tune with the paradigm here?
View 2 Replies View RelatedI have a camera application that captures a 640x480 image.I want to convert this image to grayscale.I know I have to use the setSaturatio (float sat) in the ColorMatrix method to zero but I don't know how I can set it to grayscale.
View 3 Replies View RelatedI am trying to use one of these algorithms to convert a RGB image to grayscale :
The lightness method averages the most prominent and least prominent colors:
(max(R, G, B) + min(R, G, B)) / 2.
The average method simply averages the values: (R + G + B) / 3.
The formula for luminosity is 0.21 R + 0.71 G + 0.07 B.
But i get very weird results ! I know there are other ways to achieve this but is it possible to do this way ?
here is the code...
I am wondering how do I go about writing code (or be directed to any existing relevant code), that allows me to average the grayscale values above a threshold (Otsu threshold) from a JPEG photo taken from an android device camera.
View 2 Replies View RelatedWhat I am needing is a method to get grayscale pixel data from an image or preview. I am not interested in saving the picture as a jpeg etc, just need the grayscale data.
I am aiming at API 10 (as this is the device available for testing).
On top of this, I am not having any luck getting the camera to work on the Eclipse emulator.
I need to set alternate color in list view rows but when i do that it removes/ disables the on focus default yellow background
I tried with backgroundColor
rowView.setBackgroundColor(SOME COLOR);
also with backgrounddrwable.
CODE:.........
But it wont work. is there any way we can set background color and on focus color simultaneously which will work.
Is there any process to change the default text color white to "Black" and default selection color of android "orange" to "Blue" for whole project. i am using Eclipse for Android development.
View 3 Replies View Related1. I want to use my own color for selecting ui views.
By default, android shows the selected view with background as orange. I want to show the view background color as red.
2. In the same way, I want the same behaviour should be applied to whole application.
I have seen this example:
@*android:color/secondary_text_light
What's that * asterisk doing there? What is the difference when using or not?
How to customize the color of the CheckMark color in android in a dialog. Currently , By default, the color of the checkmark is green by default. I would like to customize it to a different color of choice
View 2 Replies View RelatedIn android, when I press on a TextView, the text changes color (from white to grey). how can I disable that functionality?
View 1 Replies View RelatedI got a little textview defined in layout xml:
CODE:.........
As you can see the background color is "background_light" (this results in white color) and the text color is "primary_text_light" (this results in black color).
I would have thought that primary_text_light would result in a "light" color like white, not black ;-)
When i change "primary_text_light" into "primary_text_dark" the text color becomes color white.
Is this a bug in the naming of the default colors?