Change the underline of android textfields in Titanium Alloy - android

I am trying to change the underline color of Android textfields in Titanium Alloy using a custom theme, but for some reason it doesn't pick up my new colors(s).
I have created a theme under project/app/platform/android/res/values/awesome_theme.xml with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="awesome" parent="#style/Theme.AppCompat">
<item name="colorControlNormal">#ff0000</item>
<item name="colorControlActivated">#00ff00</item>
<item name="colorControlHighlight">#0000ff</item>
</style>
</resources>
And I have changed my tiapp.xml file to use the new theme:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<application android:theme="#style/awesome"/>
</android>
I have cleaned the project, but the text field is still showing up with the default blue underline when I rebuild the project.
What am I doing wrong here?

You have to use a different background image, go to your XML "awesome_theme.xml" and add the custom EditText style
<style name="EditTextCustomHolo" parent="android:Widget.EditText">
<item name="android:background">#drawable/apptheme_edit_text_holo_light</item>
<item name="android:textColor">#ffffff</item>
</style>
insted of using image drawble file--> apptheme_edit_text_holo_light in that EditText style you can use a drawable resource file which has a stroke , go with that one or this stroke one ,
<?xml version="1.0" encoding="utf-8"?>
<item>
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#color/white"/>
</shape>
</item>
then Just do this in your EditText:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/EditTextCustomHolo"/>
or
you can change Underline of EditText color specifying it in awesome_theme.xml. add the following tag under your style Theme.AppCompat.
<item name="android:textColorSecondary">#color/primary_text_color</item>
Note : android:textColorSecondary is used to determine the color of the back arrow and DrawerLayout hamburger icon in the ActionBar, too soo careful

Related

Android studio custom button style padding issues

After 4 months of being inactive i realized that there are some changes.
Now when you make a new button it is purple and has some padding defined. Managed to kill the purple color by editing the theme, but i still have issues with padding. When i make a new button, by default it has left and right padding 16dp, and top and bottom 4. I would not like to be forced to change every single new button to 0 padding..
i have 2 options in mind. To set padding in custom button xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="12dp" />
<solid android:color="#000000" />
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp" />
</shape>
...but for some reason this doesnt work.
Can someone figure out what can be the issue?
Or to tell me how can i change default padding values for new buttons?
Also values for some insetBotton and insetTop to be set to 0 by default and not 6
Using a Material Components theme the Button is replaced at runtime by a MaterialButton.
The MaterialButton has a default style with insetBottom and insetTop with a value of 6dp.
If you want to change globally the button style in your app you can also add the materialButtonStyle attribute in your app theme:
<style name="AppTheme" parent="Theme.MaterialComponents.*">
<item name="materialButtonStyle">#style/Widget.App.Button</item>
</style>
<style name="Widget.App.Button" parent="Widget.MaterialComponents.Button">
<item name="android:paddingLeft">....</item>
<item name="android:paddingRight">...</item>
<item name="android:insetTop">...</item>
<item name="android:insetBottom">....</item>
</style>
Go to your res folder -> values -> styles
Insert the following lines below to edit the standard button et voilà:
<style name="AppTheme" parent="Widget.AppCompat.Button">
<item name="android:minWidth">0dp</item>
<item name="android:minHeight">0dp</item>
</style>
That should work, give it a shot buddy.

Setting Background Drawable to Button in xml does not change the color Android Studio 4.2 preview

I have been doing this for years with no problem, when I need to create a button with curved corners I create a drawable with corners and a color and I use it as the background to the button I need to change, but since Android Studio 4.2 preview, it's not working any more. Can anyone help. Thanks.
Here is an example of how the drawable xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#EFB70E" />
<corners android:radius="12dp" />
</shape>
and I set that drawable as the background of my button.
In Material Design components, buttons have a default backgroundTint value set to colorPrimary that is why no matter what color you use in your button's background, it will be tinted blue(colorPrimary).
Just Add this line in the button's code : app:backgroundTint="#null"
And a better way to make your buttons round in material design:
In your themes.xml file add this :
<style name="ShapeAppearance.App.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">8dp</item>
</style>
<style name="Widget.App.Button" parent="Widget.MaterialComponents.Button">
<item name="shapeAppearance">#style/ShapeAppearance.App.SmallComponent</item>
</style>
Then if you want to apply round corners to all buttons in the app, add this line in your app's main theme :
<item name="shapeAppearanceSmallComponent">#style/ShapeAppearance.App.SmallComponent</item>
Otherwise, if you want to apply this style to specific button, add this line to it's code:
style="#style/Widget.App.Button"

How to Change the Text Selection Toolbar color which comes when we copy a text?

I am developing an application and i set "android:textIsSelectable" for the TextViews.
But my material theme is not matching with the TextSelection appBar. Is there a way by which i can change the color of that appBar ??
Attached the Image Below Check it :-
Assuming you use the appcompat-v7 library add these to your theme:¨
<!-- this makes sure the action mode is painted over not above the action bar -->
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">#drawable/myapp_action_mode_background</item>
Now I wasn't able to style the insides of the action mode (text color, icon colors) so hopefully you won't need to.
Note: If you don't use the support library prepend those style item names with android:. These will work above API 11+.
EDIT
For an action mode background with a stroke create a new drawable and update the reference. The drawable could look like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-2dp" android:left="-2dp" android:right="-2dp">
<shape android:shape="rectangle">
<solid android:color="#color/primary_dark"/>
<stroke android:color="#color/accent" android:width="2dp"/>
</shape>
</item>
</layer-list>
In your resources styles.xml: "android:textColorHighlight"
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorHighlight">#color/yellow</item>
</style>
</resources>
You can put in whatever color you choose and whatever parent theme you are using.

background of custom icon in actionbar

i am setting custom icon but its showing some white background rather then my transparent icon
here is may code that i have tried , i am using app compact actionbar
this.getSupportActionBar().setCustomView(R.layout.home_actionbar);
this.getSupportActionBar().setIcon(R.drawable.icon);
this.getSupportActionBar().setDisplayShowCustomEnabled(true);
this.getSupportActionBar().setDisplayUseLogoEnabled(true);
and here is the screen shot
You have to create a file in drawable folder. Name it "action_bar_icon_clicked", then paste this code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#color/dark_grey" />
<item android:drawable="#color/dark_grey"/>
</selector>
Then, in the style file, at the app theme add this line:
<style name="AppTheme" parent="android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/action_bar_icon_clicked</item>
</style>

Titanium Android Action Bar theme

Im using SDK 3.0 and with the xml down here I can change the tabs into Holo Dark theme. Is it possible to change fontsize, because the one I get gives me a swipeable tabBar? And can I get the color pink instead of the blue one?
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>14</tool-api-level>
<manifest>
<application android:theme="#android:style/Theme.Holo"></application>
</manifest>
</android>
Edit: I tried to follow this exampel: Android Action Bar theme But i can't get it to work. Otherwise this is exectly what I want.
You can use the ActionBar Style Generator to customize your ActionBar Theme. The tool gives you all resources you need within a "res"-folder. Just copy that folder to platform/android beneath your application's root project directory.
In your custom Manifest or directly in the tiapp.xml you refer to that theme by its name:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.myCustomActionBarTheme" />
</manifest>
</android>
This solution works very fine for me - and I hope it helps!
I'm using the ActionBarSherlock to support an Action Bar on all platforms. It provides huge custom styling opportunities. I changed the blue separator to a green one. Here's my xml:
AndroidManifest.xml
<application android:theme="#style/Theme.GreenAB"></application>
/res/values/abs_green_style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.GreenAB" parent="Theme.Sherlock.ForceOverflow">
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#drawable/green_style</item>
<item name="background">#drawable/green_style</item>
</style>
</resources>
/res/drawable/green_style.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Green Bottom Line -->
<item>
<shape android:shape="rectangle">
<solid android:color="#FF177506" />
</shape>
</item>
<!-- Color of the action bar -->
<item android:bottom="2dip">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
</layer-list>
If you don't need support on all platforms you might even use this without third-party libraries. Replace the parent theme (Theme.Sherlock.ForceOverflow) with an Android resource and remove the duplicate item entries in the style sections.
I wrote a blog post about how to use a custom Holo Theme in Titanium Mobile: http://blog.rafaelks.com/post/47898772164/how-to-use-custom-holo-theme-in-android-with-titanium.
It's similar to manumaticx answer.

Categories

Resources