Aug 2 | 9:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Aug 2 | 10:00 AM |
Bruce F. | has entered the room |
Mark M. |
howdy, Bruce!
|
Mark M. |
how can I help you today?
|
Bruce F. |
Good morning.
|
Bruce F. |
I currently have a standard ImageButton which
triggers a DatePicker dialog. I’d like to mimic the behavior on some
travel apps like Kayak which display a default day of the week/month/day
of month on a rectangular square button, and of course update the
display on the button based on user choices. Your suggestions?
|
Mark M. |
um
|
Mark M. |
are you saying that you want to replace the ImageButton with the "rectangular square button"?
|
Bruce F. |
yes
|
Mark M. |
and what specifically is the problem?
|
Bruce F. |
Getting the text on a Button/ImageButton
|
Mark M. |
call setText() on a Button to change the caption
|
Mark M. |
there is no text on an ImageButton
|
Bruce F. |
The text needs to be formatted, with different sized fonts
|
Mark M. |
you have two options
|
Mark M. |
1. Use SpannableStringBuilder and appropriate spans to do the formatting (see the Rich Text chapter)
|
Mark M. |
2. Create a snippet of HTML formatted as you wish, then use Html.fromHtml() to get a Spanned
|
Aug 2 | 10:05 AM |
Mark M. |
the results of either of those can be passed to setText()
|
Mark M. |
here is a somewhat dated list of the undocumented list of tags supported by fromHtml(): http://commonsware.com/blog/2010/05/26/htm…
|
Bruce F. |
Thank you.
|
Mark M. |
if you have another question, feel free to ask -- not exactly a crowded room today
|
Bruce F. |
I’d like to provide users with a maximum two line
EditText, with the enter button causing a tab to the next EditText. Xml
properties maxLines and actionDone aren’t accomplishing it for me.
|
Mark M. |
hmmmm
|
Mark M. |
what is happening when you press Enter (or the action button) on the 2nd line?
|
Aug 2 | 10:10 AM |
Bruce F. |
on 2.1 it works - goes to the next edit text, on
Gingerbread it starts a new line without increasing the sized of the
edittext box.
|
Bruce F. |
I didn't realize it worked on 2.1 until this moment when I tried it on the emulator.
|
Mark M. |
short of trying an InputFilter, I am not sure what else you can do
|
Bruce F. |
I'll try it then.
|
Aug 2 | 10:15 AM |
Bruce F. |
Thanks. Here's another: I have three tabs, but the
header of one is elipsized by the system. There is plenty of space
between the tabs in the action bar. I’d like to use it rather than
truncate a tab label.
|
Mark M. |
any chance you can post a screenshot, so I can see what you are referring to?
|
Bruce F. | |
Mark M. |
well, there's no space between the tabs -- it's that the tabs are equal size
|
Mark M. |
I do not think that the tab size can be adjusted,
but you are welcome to try setCustomView() rather than setText() to see
if supplying your own TextView can somehow fix matters
|
Aug 2 | 10:20 AM |
Bruce F. |
thank you.
|
Bruce F. |
Another: I'd like a two-line edittext to have the
same vertical dimension as a button, and I'm confused about the
relationship between sp and dp. Is there a way to ensure that across
devices?
|
Mark M. |
there is no relationship between sp and dp
|
Aug 2 | 10:25 AM |
Mark M. |
sp is based on the default font size, as set by the manufacturer and possibly adjusted by the user in Settings
|
Mark M. |
dp is based on screen density
|
Mark M. |
are the EditText and the Button side-by-side?
|
Bruce F. |
yes
|
Mark M. |
I'd consider wrapping them both in a RelativeLayout
|
Mark M. |
set the EditText to have your desired sp-based height
|
Mark M. |
have the RelativeLayout use android:layout_height="wrap_content:
|
Mark M. |
(give or take a ")
|
Mark M. |
have the Button be anchored to the top and bottom of the RelativeLayout
|
Mark M. |
that way, the EditText will dictate the size of the Button
|
Mark M. |
since the EditText will be taking other things into account beyond font size (e.g., line spacing, border)
|
Aug 2 | 10:30 AM |
Bruce F. |
Thank you. And since no one else is in line...
|
Bruce F. |
I think the early (pre-honeycomb?) appearance of
the spinner is large and obtrusive for my purposes, and I’m thinking of
subclassing it to convert to the lower right triangle thingy. Good/bad
idea? If I go for it, should the triangle just be a custom button?
|
Mark M. |
AFAIK, you should not need to subclass it
|
Mark M. |
what makes a Spinner is its background
|
Mark M. |
the background is different in the Holo theme set
|
Mark M. | |
Aug 2 | 10:35 AM |
Mark M. |
that's the GitHub repo for a guy trying to backport all of Holo
|
Bruce F. |
I don't have it in front of me, but I think when I tried it with Sherlock, I got the old look of the spinner
|
Mark M. |
ABS does not backport the Holo theme
|
Mark M. |
you might poke at that HoloEverywhere project and see if it has the resources you need to create a Holo-style Spinner
|
Mark M. |
without necessarily taking on the whole theme backport
|
Bruce F. |
short of that, can I simply change the background of the spinner?
|
Mark M. |
you can certainly try finding the background from a Holo theme, copying it into your project, and using it
|
Aug 2 | 10:40 AM |
Bruce F. |
Thank you very much. That's it from me.
|
Mark M. |
happy to help!
|
Bruce F. |
Bye.
|
Aug 2 | 10:50 AM |
Bruce F. | has left the room |
Aug 2 | 10:55 AM |
Mark M. | turned off guest access |
Aug 2 | 11:10 AM |
Mark M. | has left the room |