Office Hours — Today, March 13

Thursday, March 8

Mark M.
has entered the room
Mark M.
turned on guest access
Mar 13
10:05 AM
Ron T.
has entered the room
Mark M.
howdy, Ron!
how can I help you today?
Ron T.
Hi! I have a question regarding the default colors on the edittext control...
On two of my devices, when the edit control is selected there is a blue border but on one device there is an orange border. I thought that the default is orange?
Mark M.
themes are under the control of device manufacturers
they also shift occasionally in Android itself (e.g., Honeycomb)
that's part of the reason why ICS mandates that device manufacturers leave alone Theme.Holo.*
so apps using it have a consistent look across devices
Ron T.
My devices with blue are running 2.3.3 and 2.2.1. My Orange device is running 3.2.1
10:10 AM
Ron T.
When I develop, I am targeting 2.2
My real problem is...
Mark M.
your build target has nothing to do with it
Ron T.
My customer wants his app to have blue borders. He also wants the controls to have rounded corners. I've google'ed alot about the rounded corners and found an entry from 2010 with some code (XML) and some comments by you regarding the selector states. All that works fine but... when I implement it, the blue borders change to orange on those devices!!!
Mark M.
the borders are formed by the background of the widget
which is a StateListDrawable, typically defined in XML
the StateListDrawable points to other images (typically nine-patch PNGs) for each specific state
so you are in control over what the colors are
by simply creating or choosing the right nine-patch PNG files
10:15 AM
Ron T.
What is the best way to implement rounded corners and a blue rather than orange selector scheme?
Mark M.
I pretty much just wrote that
create a StateListDrawable, either copying from the SDK or one from scratch
create nine-patch PNG files for your rounded rectangles, incorporating colors as needed, for each state
Ron T.
Yes, I saw your comment in the google about the png files. So... I will have to point to a custom set of PNG files that have the blue colors, correct?
Mark M.
(or copy the ones from the SDK and modify them)
yes
bear in mind that themes shifted significantly from 2.x -> 3.x -> 4.x
so you might wind up with a couple of these (e.g., res/drawable/ and res/drawable-v14/)
in order to have stuff that looks right when applied to the base theme that the app runs upon
EditText widgets, for example, no longer have full borders when they are not selected
ideally, you just leave it all alone
Ron T.
Yes, copy them and place in the drawables/res. The google example had the XML for the rounded corners and it worked fine. I was just trying to figure out why the color changes from blue to orange when there is no orange color designation in the XML that does the rounded corners?
the XML won't have orange -- a nine-patch PNG file will have orange
10:20 AM
Ron T.
So, if I copy the PNG and modify the color on the copies then reference them I should be good to go, correct?
Mark M.
yes
for example
in android-9, we have: <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/textfield_selected" />
Mark M.
as part of the StateListDrawable that is an EditText's background
if you examine textfield_selected.9.png, you will see the orange highlight
Ron T.
One final question: What is the best way to modify the PNG? I'm a rookie at image modification!
Mark M.
best answer is to hand it to the graphic designer
second best answer is to use an image editor
a nine-patch PNG file can be edited using any PNG-capable editor, from MS Paint on up
just leave the 1-pixel-wide border around the edge alone
Ron T.
I will see if that is possible but it may not be as we are not in direct contact with them. I would prefer to do it that way (They gave me the background images for the Activities a while back)
Mark M.
(unless you want to change the stretching rules, in which case the draw9patch utility in the Android SDK is the best tool for adjusting that border)
Ron T.
Okay.
So the blue on some device and orange on others is due to the device mfgs, correct?
Mark M.
yes
10:25 AM
Mark M.
basically, they changed textfield_selected.9.png
(or the equivalent)
Ron T.
Okay! Thanks for your help! I will continue. May touch base with you again on Thursday. Over and out!
Mark M.
Thursday's chat is at 4pm Eastern
Ron T.
has left the room
10:30 AM
Al K.
has entered the room
Mark M.
howdy, Al!
10:35 AM
Mark M.
how can I help you today?
Al K.
hello.
I am trying to define a service inteface using AIDL.
This is what I wanted to define:
Map sendToCommandCenter(in Map message);
I am having trouble with the code generated from the aidl file.
The generated code has an undefined variable if I use Map as the return type of the remote method.
I am using the Eclipse IDE with the android plugin.
Mark M.
that problem sounds familiar
10:40 AM
Mark M.
hold on one moment while I do a bit more research...
Al K.
Ok,
This is a fragment of the generated code:
_result = _reply.readHashMap(cl);
Mark M.
and there is no cl
Al K.
where the variable cl is undefined .
Mark M.
that would appear to be a bug in the tools, though I do not see an issue for it on b.android.com
Al K.
Ok, I see this has happened to others.
Mark M.
you might try switching to returning a Bundle
Al K.
Ok, I'll look into that. Would returning a List also work?
Mark M.
I will also make a note to give this a try and file a b.android.com issue if I get the same results as you and that android-developers post from November I linked to above
a List might work, but I assumed you needed a Map-like structure
Bundle looks a lot like a Map
10:45 AM
Al K.
Another naive question. What are the restrictions on out and inout parameters? Do they need to occur in a certain order? Would Map as an out parameter by a possibility?
Mark M.
I am not aware of any ordering requirements
however, I am unclear if Map can be used as an out parameter
Al K.
Ok, thanks for your help.
Mark M.
this thread suggests there are problems with Map as an out parameter: http://groups.google.com/group/android-dev…
11:00 AM
Mark M.
turned off guest access

Thursday, March 8

 

Office Hours

People in this transcript

  • Al Kepner
  • Mark Murphy
  • Ron Thomas