React Native ,why can't I align picker item to right in android platform? - react-native

I tried to find the solution for ages , but it's still none working! Below is how I wrote:
<View style = {[ {flex: 0.7} ]}>
<Picker
selectedValue={this.state.selectedGender}
onValueChange={this.onValueChange.bind(this, 'selectedGender')}
>
<Item label="Please select gender" value=""/>
<Item label="Male" value="M" />
<Item label="Female" value="F" />
</Picker>
</View>

If you want to change the style of the picker items on Android, you have to change native code.
You'll have to add your style in android/app/src/main/res/values/styles.xml.
To change the picker container
Here I set, the background to null so there is not the down arrow on the left.
<style name="SpinnerStyle" parent="#android:style/Widget.Spinner">>
<item name="android:background">#null</item>
</style>
To change the selected item style
Here I set the items to be centered, the color font to be dark gray and the font size to 16.
<style name="SpinnerItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:gravity">center</item>
<item name="android:textColor">#373737</item>
<item name="android:textSize">16dp</item>
</style>
To change the drapdown items
Just as, the selected item, I want the dropdown items to have the same style.
<style name="SpinnerDropDownItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:gravity">center</item>
<item name="android:textColor">#373737</item>
<item name="android:textSize">16dp</item>
</style>
Finally
Once, you have set your styles for every element of the picker. You have to add the style to the general App theme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:spinnerStyle">#style/SpinnerStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItem</item>
...
</style>
Hope it helps !

Related

Theme ActionBar text title color issue with MaterialComponents.DayNight.DarkActionBar

I am struggling to set the dark and light mode theme color's for the title text and the background color.
My themes.xml code:
<style name="Theme.Main" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="android:textColorPrimary">#color/colorAccent</item> //PrefScreen text
<item name="android:textColorSecondary">#color/colorAccent</item> //PrefScreen summary
<item name="colorPrimary">#color/background_dark</item> //ActionBar background
<item name="colorSecondary">#color/colorPrimary</item> //fab outline, PrefCategory
<item name="colorOnSecondary">#color/OnSecN</item> //fab icon
<item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
<item name="android:statusBarColor" tools:targetApi="l">#color/background_dark</item>
<item name="android:backgroundTint">#color/background_dark</item>
</style>
Theme is applied in AndroidManifest.xml to application.
I have tried textColor and titleTextColor.

Change navigation bar color on android react native(Only on single page, not through out the app)

react-native-navigation-bar-color is not working for me.Any other solution to change nav bar color on androi in react native?
You just need to update your android style, Go to android/app/src/main/res/values/styles.xml file
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">#drawable/rn_edit_text_material</item>
<item name="android:navigationBarColor">#android:color/white</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
</style>
Just use the StatusBar of react-native.
import {StatusBar} from 'react-native'
...
...
<StatusBar backgroundColor="blue" barStyle="light-content" />
https://reactnative.dev/docs/statusbar
go into this path ..android/app/src/main/res/values find styles.xml
and add this item :
<item name="android:navigationBarColor">#212e34</item>
this is my color code #212e34 change it what ever you want

Customise style of image select react native image picker

How do you change the colour of the react-native-image-picker choose from library screen?
I have added the following to styles.xml
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">#e7bd61</item>
<item name="android:colorPrimary">#e7bd61</item>
<item name="android:colorPrimaryDark">#e7bd61</item>
<item name="android:colorAccent">#e7bd61</item>
<item name="android:textColor">#e7bd61</item>
<item name="android:statusBarColor">#color/blue</item>
</style>
This code allows the Dialog to be styled however doesn't allow styling on the choose from library screen.

Appcelerator Titanium: How do I change SearchView colors on Android? (hintText and cross icon)

I have a SearchView which is dark and its hinttext and its cross icon are black, so I want to set the color of these two things to white.
I am using a custom theme for Android but it does nothing to the SearchView. This is how my custom theme xml file looks like:
<resources>
<style name="Theme.MyApp" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:spinnerItemStyle">#style/MySpinnerItem</item>
<item name="android:actionBarStyle">#style/SearchViewTheme</item>
</style>
<style name="SearchViewTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:textColorSecondary">#FFFFFF</item>
<item name="android:textColorHint">#CCCCCC</item>
</style>
<style name="MySpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:textSize">14dp</item>
</style>
</resources>
I found a solution. If anyone wants to know what I did:
I just deleted this line:
<item name="android:actionBarStyle">#style/SearchViewTheme</item>
And then, I added this to the .tss file where the SearchView is:
"Window[platform=android]" : {
theme : "SearchViewTheme"
}

how to customize border of Icon TextBox Form in Native-Base?

i use Native-Base in my react project. and i want to customize width of border Icon TextBox form in Native-Base.
this my code
<Item>
<Icon active name='lock' />
<Input placeholder='password'/>
</Item>
this is the show
so, how to customize the margin right in the border?. thanks
Try this:
<Item>
<Icon active name='lock' style={{borderWidth: 10}}/>
<Input placeholder='password'/>
</Item>