Android RatingBar numStart not working - rating

I have simple RatingBar in my app. and i set numStarts="5" but it show more then 5 star. when i set android:layout_width="match_parent" I tried to several tutorials but also did't work, as per doc numStarts for show number of starts but in my case it did't work. i go through doc and several tutorials but did't get any solution.
but i want to only 5 stars in rating bar.
my rating bar is given below.
<RatingBar
style="#style/customRatingBar"
android:id="#+id/course_rating_bar"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:numStars="5"
android:isIndicator="false"
android:stepSize="1.0"/>
This is my custom style
<style name="foodRatingBar" parent="#android:style/Widget.RatingBar">
<item name="android:progressDrawable">#drawable/ratingstars</item>
<item name="android:minHeight">22dip</item>
<item name="android:maxHeight">22dip</item>
</style>
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+android:id/background"
android:drawable="#drawable/star_empty" />
<item android:id="#+android:id/secondaryProgress"
android:drawable="#drawable/star_empty" />
<item android:id="#+android:id/progress"
android:drawable="#drawable/star" />
</layer-list>

You have to set android:layout_width="wrap_content" rather than "match_parent". Then you will get the 5 stars.

Related

Nativescript-vue: how to change datepicker color?

In my setting page, a Settings.vue file I've my DatePicker
<template>
<Page>
<DatePicker/>
</Page>
</template>
I need to change the default style.
Note: actually I'm working specifically on Android, but please, answer keeping in mind I need the same colors on both Android and iOs; thanks,
I tried (in app.scss file
Datepicker {
color: white;
}
Without success, as you can see my android emulator is using a near-black color.
Following this guide, I changed colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ns_primary">#577eac</color>
<color name="ns_primaryDark">#577eac</color>
<color name="ns_accent">#ffffff</color>
<color name="ns_blue">#272734</color>
</resources>
Then I changed styles.xml
<style name="AppTheme" parent="AppThemeBase">
<item name="android:datePickerStyle">#style/SpinnerDatePicker</item>
</style>
<style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:datePickerMode">spinner</item>
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
</style>
Note: I specified I want the spinner, but it's actually the default, I think.
I did a clean run
tns debug --hmr --clean
The problem: actually, the android DatePicker is still rendered using default colors, no my primary or accent colors as defined.
Similar question:
Nativescript Datepicker change text color - Uses the same solution, so it's useless for me because this solution doesn't works (for me, actually)

ActionBar logo not showing

i have declared the logo in the manifest file like this :
android:allowBackup="true"
android:logo="#drawable/ic_launcher"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme"
and the custom theme is like this :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:icon">#drawable/ic_launcher</item>
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
<item name="icon">#drawable/ic_launcher</item>
</style>
</resources>
but the logo is not showing in the actionbar, i have tried many ways but not working, can anybody pls help me ?
With the new appcompat 21, the pattern is changed.
The Action Bar follows the material design guidelines and uses a Toolbar.
As you can read here:
The use of application icon plus title as a standard layout is
discouraged on API 21 devices and newer.
If you would like an application icon, you can use the method setLogo().
You should read this official post.

custom background colors for ActionBar items

I have an ActionnBar for which I am trying to set the background color and I would like to change the background color of each items in the ActionBar with other color on "Tap".
This thing is not working for some reason. I have tried changing various options given in other topics.Nothing works not sure why. What is the right way to do it. I followed Android Developer website to do this and still is not reflected. Thanks for your time
My styles.xml
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:actionButtonStyle">#style/MyActionBarButton</item>
<item name="android:selectableItemBackground">#drawable/circular_tap_state</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#000000</item>
</style>
<style name="MyActionBarButton" parent="#android:style/Widget.Holo.Light.ActionButton">
<item name="android:actionBarItemBackground">#drawable/custom_settings_button</item>
</style>
custom_settings_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:color/holo_orange_light"
android:state_pressed="true" />
<item android:drawable="#android:color/holo_orange_light"
android:state_focused="true" />
<item android:drawable="#android:color/holo_orange_dark" />
</selector>
custom action bar - action_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/today"
android:showAsAction="always"
android:title="#string/menu_today"/>
<item
android:id="#+id/menu_list"
android:icon="#drawable/ic_custom_calender_icon_normal_state"
android:showAsAction="always"
android:title="#string/menu_calendar" />
<item
android:id="#+id/add_event"
android:icon="#drawable/ic_custom_add"
android:showAsAction="always"
android:title="#string/menu_add" />
<item
android:id="#+id/calendar_settings"
android:icon="#drawable/ic_custom_settings"
android:showAsAction="always"
android:title="#string/menu_settings" />
</menu>

Custom Android Theme for Titanium (no ActionBar, custom splashscreen)

im using Titanium SDK 3.3.0 and want to disable the "new" ActionBar in Android with the theme solution.
Besides a want to use a 9-Patch-Image as splashscreen/loadingscreen.
Referring to the docs and guides:
http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Action_Bar
http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Themes
I have the following Project-Setup:
files for splashscreens:
/platform/android/res/drawable-ldpi/splash.9.png
/platform/android/res/drawable-mdpi/splash.9.png
/platform/android/res/drawable-hdpi/splash.9.png
/platform/android/res/drawable-xhdpi/splash.9.png
theme file: /platform/android/res/values/gsgptheme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.GSGP" parent="Theme.AppCompat">
<!-- Depending on the parent theme, this may be called android:windowActionBar instead of windowActionBar -->
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:installLocation="auto"
android:versionCode="21" android:versionName="3.1.1">
<application android:theme="#style/Theme.GSGP"/>
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14"/>
<supports-screens android:anyDensity="false"/>
</manifest>
</android>
The Problem is: Titanium doesn't seem to load my theme. On startup I see the default loadingscreen and still have an actionbar. Can anyone see my mistake?
Need to add something similar to the following in your tiapp.xml file under the android application node. Replace "YourApp" in .YourAppActivity with whatever your app name is.
<activity android:name=".YourAppActivity" android:label="#string/app_name" android:theme="#style/Theme.GSGP" android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

Modifying style does not work well

I'm changing the UI of my app to green colors. In the ActionBar, I use a ShareActionProvider to share data to other users, but this menu item doesn't get the same color as the other menu items. However, its dropdown listview has the correct colors.
I'm running my app in GingerBread, so when I press menu key, a menu item appears but it also has the wrong colors.
I have used Android Action Bar Style Generator, but there is something I'm missing. This is my code in /res/values:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_newtheme</item>
<item name="actionBarStyle">#style/ActionBar.Solid.NewTheme</item>
<item name="popupMenuStyle">#style/PopupMenu.NewTheme</item>
<item name="dropDownListViewStyle">#style/DropDownListView.NewTheme</item>
<item name="actionDropDownStyle">#style/DropDownNav.NewTheme</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/NewTheme.Widget</item>
</style>
<!-- ActionBar style -->
<style name="ActionBar.Solid.NewTheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/action_bar_gradient</item>
</style>
<style name="PopupMenu.NewTheme" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/background_gradient</item>
</style>
<style name="DropDownListView.NewTheme" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_newtheme</item>
</style>
<style name="DropDownNav.NewTheme" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_newtheme</item>
<item name="android:dropDownSelector">#drawable/selectable_background_newtheme</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="NewTheme.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.NewTheme</item>
<item name="dropDownListViewStyle">#style/DropDownListView.NewTheme</item>
</style>
Is there any missing item? Thanks in advance
I finally got it working myself. I had to add:
<item name="android:listChoiceBackgroundIndicator">#drawable/selectable_background_realestate</item>
in *themes_base.xml* in values-v14 and
<item name="listChoiceBackgroundIndicator">#drawable/selectable_background_realestate</item>
in themes_base.xml in values for the correct highlight color when pressing a list item.
I also had to change actionBarItemBackground in themes_base.xml (values and values-v14) to reference my drawable so that the share icon would get the same highlight.
Finally to get the right color of the dropdown menu item I had to change android:popupBackground to #drawable/menu_dropdown_panel_realestate in styles_base.xml (values and values-v14) for Widget.AppCompat.Base.ListPopupWindow
The drawables I referenced in my answer were generated using Android Asset Studio for AppCompat
I think I can help you solve your Gingerbread problem.
That menu is called a "panel" in the AppCompat style & theme .XML files.
So to override it with your own selector colour, this is what I suggest:
In your custom theme, CustomActionBarTheme, add this line:
<item name="panelMenuListTheme">#style/Theme.NewTheme.CompactMenu</item>
And add these two styles:
<style name="Theme.NewTheme.CompactMenu" parent="#style/Theme.AppCompat.CompactMenu">
<item name="android:listViewStyle">#style/myCustomMenuStyle</item>
</style>
and
<style name="myCustomMenuStyle" parent="#style/Widget.AppCompat.ListView.Menu">
<item name="android:listSelector">#drawable/newtheme_list_selector_holo_light</item>
</style>
note: the #drawable/newtheme_list_selector_holo_light is an xml resource that I got from the Android Holo Colors Generator.
I suggest you use the website, by the way, you only need the resources of the "List Selector" in this case, and grab the following resources from the ZIP file that it outputs, and put them in your drawable folders.
Specifically:
newtheme_list_selector_holo_light.xml > in res/drawable
newtheme_list_selector_background_transition_holo_light.xml > in res/drawable
And the mdpi, hdpi, xdpi and xxdpi of the following .9.png resources:
newtheme_list_selector_disabled_holo_light.9.png
newtheme_list_pressed_holo_light.9.png (similar to the png Action Bar Generator created)
newtheme_list_longpressed_holo.9.png
newtheme_list_focused_holo.9.png (similar to the png Action Bar Generator created)
A bit later however it might help. In GingerBread, when you press menu key, the menu item which appears at the bottom can be customize by the following attribute itemBackground:
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">#drawable/selectable_background_newtheme</item>
</style>
Then, apparently to customize the ShareActionProvider item pressed, you need this attribute:
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:selectableItemBackground">#drawable/selectable_background_newtheme</item>
</style>