Android Studio, change EditText selected text pointer colors - android-layout

I've been making a chat for a project of mine but how to change the color of these pointers?

Setting the android:textCursorDrawable attribute to #null should result in the use of android:textColor as the cursor color.
or you can use Style look like this
<style name="AppTheme.EditText" parent="#style/Widget.AppCompat.EditText">
<item name="android:textColor">#color/white</item>
<item name="android:textColorHint">#8AFFFFFF</item>
<item name="android:background">#drawable/edit_text_background</item> // background (bottom line at this case)
<item name="android:textCursorDrawable">#color/white</item> // Cursor
<item name="android:textSelectHandle">#drawable/my_white_icon</item> // For pointer normal state and copy text state
<item name="android:textSelectHandleLeft">#drawable/my_white_icon</item>
<item name="android:textSelectHandleRight">#drawable/my_white_icon</item>
</style>
hope it help

Related

How to change the color of active indicator bottombavigationview material You? material3

I want to change the color of the selected area in the bottom navigation view material 3, but the color does not change in any way. I've tried selector, background, background Tint, and styles. All unsuccessfully.
Currently like this.
It should be like this.
You can change indicator color by overridng it's default style.
Default itemIndicatorStyle :
<style name="Widget.Material3.BottomNavigationView.ActiveIndicator" parent="">
<item name="android:width">#dimen/m3_bottom_nav_item_active_indicator_width</item>
<item name="android:height">#dimen/m3_bottom_nav_item_active_indicator_height</item>
<item name="marginHorizontal">#dimen/m3_bottom_nav_item_active_indicator_margin_horizontal</item>
<item name="shapeAppearance">#style/ShapeAppearance.Material3.NavigationBarView.ActiveIndicator</item>
<item name="android:color">?attr/colorSecondaryContainer</item>
just override the style according to your preference :
<style name="App.Custom.Indicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
<item name="android:color">#color/blue</item>
</style>
And then add this line to your bottomNavigationView xml code :
app:itemActiveIndicatorStyle="#style/App.Custom.Indicator"
you can use this function for change indicator color:
findViewById<BottomNavigationView>(R.id.bottomNavigationView) .itemActiveIndicatorColor = getColorStateList(R.color.white)
and set this annotatin for your onCreate function #RequiresApi(Build.VERSION_CODES.M)
look in the screenshot

ListPreference list option text color

I'm trying to style a ListPreference Dialog to suit a dark theme, with the accent color given by my code. However, the text color for each option does not seem to change no matter what attribute I add to it. Is there a way to do this without having to create my own Dialog class?
P.s. I have tried the solution given in this answer: ListPreference text color
And no, it does not seem to work.
Here's the required code from styles.xml: (Not the entire code but it's all I need to show)
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="dialogPreferenceStyle">#style/DialogBoxTheme</item>
<item name="listDividerAlertDialog">#style/DialogBoxTheme</item>
<item name="alertDialogStyle">#style/DialogBoxTheme</item>
<item name="alertDialogTheme">#style/DialogBoxTheme</item>
</style>
<style name="DialogBoxTheme" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:layout_gravity">center</item>
<item name="android:layout_width">320dp</item>
<item name="android:layout_height">200dp</item>
<item name="android:layout_marginStart">16dp</item>
<item name="android:layout_marginEnd">16dp</item>
<item name="android:textColorPrimary">#color/colorPrimary</item>
<item name="android:textColorSecondary">#color/colorPrimary</item>
<item name="android:textColorHint">#color/Silver</item>
<item name="android:textColorTertiary">#color/colorAccent</item>
<item name="android:textColor">#color/colorPrimary</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:background">#color/cpWhite</item>
<item name="textColorAlertDialogListItem">#color/colorPrimary</item>
<item name="android:textColorAlertDialogListItem">#color/colorPrimary</item>
</style>
(note that I've set colorPrimary and colorAccent to vary with the theme)
Here's the output that it gives:
ListPreference Dialog appearance
Answering my own question:
I forgot to add the attribute
<item name="android:alertDialogTheme">#style/DialogBoxTheme</item>
to the AppTheme in styles.xml.

A Style Resource related 'Widget' error in android application --

I'll describe my problem first. I'm trying an android app. Doing it using Xamarin Android. I've done the parts I need, the necessary code; but Compiling my code gives me some errors in the Styles.xml file.
The error is like this::
Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget'. (APT0000) (TestALLApp)
Basically 5 errors, the above error repeating itself 5 times for the 5 style definitions in the Stylex xml file.
This is my Styles.xml file::
<resources>
<style name="Widget.SampleContentContainer"> <---- error shown here
<item name="android:paddingTop">#dimen/vertical_page_margin</item>
<item name="android:paddingBottom">#dimen/vertical_page_margin</item>
<item name="android:paddingLeft">#dimen/horizontal_page_margin</item>
<item name="android:paddingRight">#dimen/horizontal_page_margin</item>
</style>
<style name="Widget.SampleDashboard.Grid" parent="Widget">
<item name="android:stretchMode">columnWidth</item>
<item name="android:columnWidth">200dp</item>
<item name="android:numColumns">auto_fit</item>
<item name="android:drawSelectorOnTop">true</item>
<item name="android:horizontalSpacing">#dimen/margin_medium</item>
<item name="android:verticalSpacing">#dimen/margin_medium</item>
</style>
<style name="Widget.SampleDashboard.Item" parent="Widget">
<item name="android:background">#drawable/sample_dashboard_item_background</item>
<item name="android:paddingTop">#dimen/margin_small</item>
<item name="android:paddingLeft">#dimen/margin_medium</item>
<item name="android:paddingRight">#dimen/margin_medium</item>
<item name="android:paddingBottom">#dimen/margin_medium</item>
</style>
<style name="Widget.SampleDashboard.Item.Title" parent="Widget">
<item name="android:layout_marginBottom">#dimen/margin_tiny</item>
<item name="android:textAppearance">?android:textAppearanceLarge</item>
<item name="android:textColor">#09c</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">24sp</item>
</style>
<style name="Widget.SampleDashboard.Item.Description" parent="Widget">
<item name="android:textAppearance">?android:textAppearanceSmall</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
You can see the line on which the error is shown. Among the references I added to my project were
Xamarin.Android.Support.v4
Xamarin.Android.Support.v7.RecyclerView
That's All. As per the error message I suppose, 'Error retrieving parent for item' should mean it cannot find/locate a parent called 'Widget'. I did search for any nuget package like Xamarin Widget, anything of that name or similar name doesn't exist. At least my nuget package search cannot list/find anything like that. Or is it something to do with a style element definition called 'Widget' too in that xml file? So what is the actual correct thing to be done please, if someone could show me, it'd help me very much. Is it just a missing nuget package? If so what is the proper correct name of it please['widget'].
Please help me a little on this matter.
Thanks so much.
As I have used it before, the parent attribute's value is the parent style that you will start with, then override the various properties within there. For me, I have always used parent attribute values such as "#android:style/Theme.Holo.Light", .Dark, and so on. Unless there is a theme named Widget, I don't see this working.
PS. Obviously, the holo styles were first introduced in android 3.x/4.x, so I doubt that they would work in previous versions of android without including some other stuff to make them work. You used the Xamarin.Forms tag for the question, so this won't be a big deal since XF only runs on android 4 and later.

AppCompat ActionBar Background Color

I have this style.xml inside my Android app:
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="OrangeTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/OrangeTheme.OrangeActionBar</item>
<item name="android:windowActionBar">true</item>
</style>
<style name="OrangeTheme.OrangeActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#color/orange</item>
<item name="background">#color/orange</item>
<item name="android:backgroundStacked">#color/orange</item>
<item name="android:backgroundSplit">#color/orange</item>
<item name="android:titleTextStyle">#style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/black</item>
</style>
I have searched StackOverflow and Google, but nothing helped. I wasn't able to change the ActionBar background color.
Inside my MainActivity, I use this code:
public void restoreActionBar() {
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
}
I tried not to use AppCompat, but then my name has a lot of errors. It extends ActionBarActivity. If I change it to FragmentActivity I can't use getSupportActionBar() and without it my getActionBar(), is always null.
minSdkVersion 19
targetSdkVersion 21
So right now I am not able to change it. I tried renaming the parent of my style theme. I tried using andrioud:background and background. The only thing that is changing is when I use another parent like
Theme.App.Compat.Light or Theme.AppCompat.Light.DarkActionBar.
Does someone have an idea, how I could be able to change the colors and other stuff, on runtime?
With new AppCompat-v7 (v21) you can use new color theming attributes. See here.
Or alternatively you have to use <item name="actionBarStyle"> property (without prefix android).
To use background color with AppCompat, you need to also define the item name without the android: attribute.
for example:
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:background">#color/action_bar_background</item>
<item name="background">#color/action_bar_background</item> //<--background item without the android attribute
</style>
and then in your custom theme do the same thing for the custom actionbar style:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>

How to set background image for IcsSpinner and its drop down view resource using action bar sherlock in android

How to add style for IcsSpinner using action bar sherlock in android. If anyone know how to set different background image for IcsSpinner and Drop down view resource
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="android:actionDropDownStyle">#style/DropDownNav</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView</item>
</style>
<style name="DropDownListView" parent="#android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background</item>
</style>
<style name="DropDownNav" parent="#android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/spinner_background_ab</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel</item>
<item name="android:dropDownSelector">#drawable/selectable_background</item>
</style>
Check out ActionBar Style Generator

Resources