Adding Android styles to Appcelerator View - android

I'd like to add styles defined in /app/platform/android/res/values to an appcelerator Button.
<style name="textAppearanceButton" parent="#android:style/TextAppearance.Material.Widget.Button">
<item name="android:textAllCaps">false</item>
</style>
When I use this code, it will apply to all buttons - which i don't want.
Is it possible to add it on selected buttons?

At the moment this is not possible. I did create a feature request for this some time ago that you can watch to show your interest:
https://jira.appcelerator.org/browse/TIMOB-19904

Related

xamarin android alignParentRight style

can you tell me how can I add alignParentRight into my xml style?
<style name="My_Style">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">75dp</item>
<item name="android:background">#color/Gray_75</item>
**<item name="android:alignParentRight">true</item>**
</style>
yes but I need to add it programatically for dynamic and I will add only style and thats all.
Generally you can't do that programmatically. What we can do is:
Create two different styles, one with <item name="android:alignParentRight">true</item> and the other one not, apply them to the control when it is needed. Since in which scenario of your styles will be used is not clear in your question, maybe you can look into State List.
I personally think it is more straight if we directly set the Layout Parameters in code behind, for example:
var parameters = btn.LayoutParameters as RelativeLayout.LayoutParams;
parameters.AddRule(LayoutRules.AlignParentRight);
The btn in this code refer to a Button control.

android -best approach to repetitive buttons

I want to create the following pseudo layout in android and I'd like some help to determine the best approach:
The months of the year will all be listed in buttons and when the user clicks on them an action will occur. The day of the month gets stored to storage if you need to know. The size of the circles are all the same and their behavior is identical, just their name is different (and they each store their own name of course). What is the best UI approach I can take in android to do this? I thought of a few things:
obvious create 12 buttons for each day of the month and have onclicks that read there text and store it.
create a custom button and programatically add 12 buttons to a linearLayout in code.
could I somehow use a plural in android to get this done ?
Android plurals is for handling strings with numbers, which doesn't seem to apply to your situation.
For large quantities of UI elements you may wish to use styles to cut down on duplication of code. Also any future changes you make that are part of the style will only have to be done once, instead of twelve times. Here is an example button style FYI:
<resources
<style name="GroovyButtons">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">13sp</item>
<item name="android:textColor">#color/text_color</item>
<item name="android:background">#drawable/button_custom</item>
</style>
</resources>
Save this code into styles.xml, which is inside values directory in the res folder. Then in each button you reference the button style:
style="#style/GroovyButtons"
Any attributes that you repeat in the XML layout will override what you have in the style. Overriding attributes in your styles is of course completely optional.

android 4.2 how to get main color of current theme

In android 4.2 we have the possibility to select theme in device settings.
Default theme is equivalent to using #android:color/holo_blue_light as main color.
The question is what tag to use in order to get main color (blue_light, mint, mocha, raspberry) in my own style? If I use #android:color/holo_blue_light, when user switches to mint, part of user interface is in mint color (parts not modified by myself) and part in blue_light (parts modified by myself). I spent many many hours and it's seems there is no any solution.... Perhaps any workaround....?
I even tried to analyse Android styles and theme sources and still no answer:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
At the end I'm posting part of my style code (on the request of one users here):
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showHome</item>
<item name="android:background">#android:color/holo_blue_light</item>
<item name="android:backgroundStacked">#android:color/holo_blue_light</item>
<item name="android:backgroundSplit">#android:color/holo_blue_light</item>
</style>
Instead of using #android:color/holo_blue_light i should use probably something like #android:color/holo_main_color but the problem is it seems not to exist.

Editing the underbar on a tab in Android

Hey guys I am newer to Android development and I am trying to to figure out how to edit the underbar that is on the tabs when one is selected. I have this:
<item name="android:actionBarTabBarStyle">#style/Theme.test.tabbar.style</item>
Which points here:
<style name="Theme.test.tabbar.style" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/black</item>
<item name="android:actionBarItemBackground">#color/yellow</item>
</style>
This works great except the android:actionBarItemBackground So I was wondering what do I need to point to in order to edit the active bar that shows underneath a tab you are active on?
David
Create a custom theme using this online services and then aplly the theme (remember to copy all the resources in your project!)
http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html

How to change style from code? Want to achieve skins

How to change a style from code?
I got a style used all across my app, for all buttons. If the user changes the skin of the app, the background of this style should change.
<style name="ActionBtn">
<item name="android:layout_width">#dimen/action_btn_width</item>
<item name="android:layout_height">#dimen/action_btn_height</item>
<item name="android:background">#drawable/btn_frame_bgstate</item>
<item name="android:padding">#dimen/action_btn_padding</item>
<item name="android:layout_margin">#dimen/action_btn_margin</item>
</style>
So far the only idea I got is to make a custom button that itself chooses its background on creation.
I have not found any good, generic way for skinning android apps yet, but if I could change styles from code, that would do the trick.
All suggestions welcome!
1) Create different themes for your skins.
2) Set those themes programatically using following code in your onCreate method.
setTheme(resid);
resid is the id of your theme.

Categories

Resources