I am creating the app which consists of Dial pad.
I want to use two strings in a single button.One is having one set of style and another one having another set of style in style.xml.
Is there any way to do this in XML.
I want the text in the button to be as follows
android:text= #style 2 #style abc
There are some complex ways to do this involving Spannables, but depending on what you want to do, you may be able to get away with Html.fromHtml() and am html-formatted string resource.
Related
I am building an app that uses simple text and I would like to add an option to change the text color.
My question is would the most efficient way to do this be to assign all text views to a single STYLE resource and change the values of the STYLE resource ( if this is even possible)
or
would it be better to make multiple style resources and some how programmatically change every single View's style?
Is there anyway to inherit style from a parent or put all of the Views into a single object so its easier to just change the style of that one object?
I need to create a custom button control that will inherit from the same Android style as all other buttons in my application. However, I want to be able to add several lines of text where some characters of the text will be in different colors. Is there anyway to achieve this, I can't seem to see a way?
Currently I have created a view that looks like a button by drawing the background, this is ok but I want the background etc to change with the application style.
You should make your button descend from the generic theme for Widget.Button. This way you can ensure that all the default settings will come through for you.
I am looking to format text line by line in a text view or similar. I want to be able to have line by line justifcation and formatting, almost like a word document (though nothing like as extensive)
I basically need to be able to have a continuous document with some parts right justified, some parts centered. Some bold, some not and some with a coloured background and some white. Also alowing the user to choose font.
Can someone recommend an decent approach to this please.
thanks
TextView/EditText operates on fairly rich text described by the various style span objects here: http://developer.android.com/reference/android/text/style/package-summary.html
For example you can use this to build text containing those various style spans: http://developer.android.com/reference/android/text/SpannableStringBuilder.html
SpannableStringBuilder is-a CharSequence, so it can be set as the text in a TextView. Though more often you probably just want to use TextView.getEditableText() to return the Editable interface to the text inside of the text view which allows you to modify its contents including style spans.
TextView supports most of what you are asking for through style spans, though justification is applied per-paragraph and not per-line. (Per-line is weird... I don't think even Word does such a thing?)
I would recommend using multiple TextViews. Possibly, one for each line if you really need the text that different. You can customize each one however you want fairly easily. If you haven't already, take a look at the documentation: http://developer.android.com/reference/android/widget/TextView.html
Then, you could use a RelativeLayout or a LinearLayout to position them however you need. Just ask if you have any other questions.
I want to change the style of a button in an android app. here is a picture that has both kinds of buttons, the one that I have now, and the one that I want to switch to:
the kinds of buttons that I am using now, look like any of the letters on that keyboard. the ones that I want to use like like the arrows. I would I go about changing this. I prefer to do it in xml but I can do it in java if that is the only way. Thanks
change the background of the Button to a png image with arrows!
in XML use android:background="#drawable/yourimage"
To get more sophisticated control check here,
Standard Android Button with a different color
I have a column of Checkboxes and associated EditTexts and I want one pair of these to have a distinct appearance because it has a distinct significance.
Short of writing custom controls, or using custom drawables, does Android have any way to style or alter the appearance of basic controls like buttons, checkboxes, etc, in the XML where the control is declared? Or is there just one native style or appearance for all Android Checkboxes, Buttons, EditTexts, etc?
Thanks in advance.
You can almost custom everything related to style:
http://developer.android.com/guide/topics/ui/themes.html
In fact, an Android Button is just a TextView with different style. In source code, the Button is just an extend to TextView with no overriding.