how to change the text size in "showcaseview" library - android

Is there a way to change text and tile size in showcaseview?
I cant find in the code where the text size is set.
Thanks,
Ilan

You can use a theme, which takes styles for title text appearance and detail text appearance. These can be used to change the text size.
The sample styles.xml shows how to customise these attributes. So to change the text size of the title, you'd add a textSize attribute to the CustomTitle.

it's very simple, just need to add into style file as i have mentioned below:
<style name="CustomShowcaseTheme2" parent="ShowcaseView">
<item name="sv_backgroundColor">#90000000</item>
<item name="sv_showcaseColor">#25467A</item>
<item name="sv_buttonText">Close</item>
<item name="sv_titleTextAppearance">#style/CustomTitle2</item>
<item name="sv_detailTextAppearance">#style/CustomText2</item>
</style>
<style name="CustomTitle2" parent="TextAppearance.ShowcaseView.Title.Light">
<item name="android:textColor">#color/colorPrimary</item>
<item name="android:textSize">26sp</item>
</style>
<style name="CustomText2" parent="TextAppearance.ShowcaseView.Detail.Light">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">20sp</item>
</style>

Related

Change CalendarView weekday name's layout of DatePickerDialog

I'm trying to customize a CalendarView of the DatePicker from DatePickerDialog. I already changed DatePickerDialog's background and button label color style, thanks to excellent Vikram's answer. Now I want to change layout of weekday name abbreviation inside CalendarView. Change their background color and text color.
Looking inside styles_materials.xml file from AndroidSDK folder values, this style is there:
<style name="Widget.Material.Light.CalendarView" parent="Widget.CalendarView">
<item name="selectedWeekBackgroundColor">#330066ff</item>
<item name="focusedMonthDateColor">#FF000000</item>
<item name="unfocusedMonthDateColor">#7F08002B</item>
<item name="weekNumberColor">#7F080021</item>
<item name="weekSeparatorLineColor">#7F08002A</item>
<item name="weekDayTextAppearance">#style/TextApp earance.Material.CalendarViewWeekDayView</item>
<item name="calendarViewMode">material</item>
</style>
I've overrided and applied my custom style in styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:calendarViewStyle">#style/CustomDatePickerStyle</item>
</style>
<style name="CustomDatePickerCalendarView" parent="android:Widget.Material.Light.CalendarView">
<item name="android:selectedWeekBackgroundColor">#color/viking</item>
<item name="android:focusedMonthDateColor">#color/viking</item>
<item name="android:unfocusedMonthDateColor">#color/viking</item>
<item name="android:weekNumberColor">#color/viking</item>
<item name="android:weekSeparatorLineColor">#color/viking</item>
</style>
I've made a test setting most of the parameters with the same color. But it didn't work. Why the style cannot be applied?
EDIT:
To be more clear, I want to change the hightlighted part:

What style would I need for an AlertDialog to bold?

I have an AlertDialog with buttons which I'd like to set to bold. I find the default style to be very thin:
but when I set the style as such:
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:textColorPrimary">#color/gray_dark</item>
<item name="colorAccent">#color/blue</item>
<item name="android:buttonStyle">#style/buttonStyle</item>
</style>
<style name="buttonStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textStyle">bold</item>
</style>
I find the result to be, erhm, much bolder than I'd like:
I was aiming for something like this:
The screenshot is from WhatsApp. Are they using a different font or is it something I can replicate just by styling my XML file?
Based on the answer here, it seems that the correct style for what I want to achieve is adding these lines to the button style:
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textStyle">normal</item>
Now I have the wanted "not so bold" look!

change appcompat dialog title background to full width?

I want to change title color background(green) to full width.
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#000000</item>
<item name="android:textColorPrimary">#5c5c5c</item>
<item name="android:background">#fbdd9d</item>
<item name="android:windowTitleStyle">#style/TitleDialogTextStyle</item>
</style>
<style name="TitleDialogTextStyle" parent="Base.DialogWindowTitle.AppCompat">
<item name="android:textColor">#ffffff</item>
<item name="android:background">#color/green</item>
</style>
Please find attached snap. I want green color to full width.
I made a lot of tries, I never succeded to change the color defining a custom
android:windowTitleStyle or a android:windowTitleBackgroundStyle.
It only works using the following trick, add to your custom dialog style :
<item name="android:topDark">#color/your_color</item>
And the title background will be colored as you want.

Android - Change text colour of the bottom button bar

I'm modifying downloads (for 4.3 Jellybean) and I can't change the colour of the text on the bottom button from black to white. Is it possible to change the text colour without giving the button its own style by adding an item in the app theme? Here is my Styles.xml:
<style name="DownloadListTheme" parent="#android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
<item name="android:textAlignment">viewStart</item>
<item name="android:layoutDirection">locale</item>
<item name="android:actionBarStyle">#android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse</item>
<item name="com.sonyericsson.uxp:extendedLookAndFeel">true</item>
<item name="android:textColor">#android:color/white</item>
</style>
Yes, you can accomplish this pretty easily, just override your theme in styles.xml like this:
<style name="MyButtonStyle"
parent="#android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
<item name="android:textColor">#android:color/white</item>
</style>
For more information, see the documentation.

textColor not applied when used as them

I have a style that includes textColor, textSize, textStyle and typeface. When applied directly to an EditText widget, the color of the text is as specified (as well as the other attributes), but when applied as a theme to the activity or the entire application, the size is fine but the color is not applied. What I am missing?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="fap" parent="android:Theme.Holo">
<item name="android:textSize">24sp</item>
<item name="android:textColor">#FF0000</item>
<item name="android:textStyle">normal</item>
<item name="android:typeface">normal</item>
</style>
</resources>
This is quite simple : you are not overriding android default style, your just creating a new one which extends android:Widget.EditText. Thus, the style is not applied.
To correct this, into your theme definition, just add :
<item name="android:editTextStyle">#style/fap</item>
Now, each time Android instanciate an EditText, when it load default style values, it will find your fap style.
Edit:
searching through android's source code is very usefull. Check https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/attrs.xml
https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/themes.xml
https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/styles.xml
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/EditText.java
for example.
EditText widget just can't get these parameters from an activity theme. It gets its default style from the android:editTextStyle parameter of the activity theme. So you have to create your own style:
<style name="MyEditText" parent="android:Widget.EditText">
<item name="android:textSize">24sp</item>
<item name="android:textColor">#FF0000</item>
<item name="android:textStyle">normal</item>
<item name="android:typeface">normal</item>
</style>
And then set it as EditText style in the activity theme:
<style name="fap" parent="android:Theme.Holo">
<item name="android:editTextStyle">#style/MyEditText</item>
</style>
Hope this will work because I haven't tried this code.

Categories

Resources