I am trying to enlarge the text size on all of my applications dialog buttons via styles. The following code will change the buttons background colour and even the text case but for some reason the textSize item is not honoured:
<style name="MyAppTheme" parent="@android:style/Theme.Holo">
<item name="android:dialogTheme">@style/MyApp.Dialog</item>
<item name="android:alertDialogTheme">@style/MyApp.Dialog.Alert</item>
</style>
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>
<style name="MyApp.Dialog.Alert" parent="@style/MyApp.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="MyApp.BorderlessButton" parent="@android:style/Widget.Holo.Button.Borderless">
<item name="android:textSize">50sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:background">#800</item>
</style>
Why is the textSize not being read? What do I have to do to make it larger?
To change the font size of a button, use the font-size property.
Press Ctrl+A to select all the text in your document. Click Home > Shrink Font one or more times. As you click Shrink Font, Word decreases the size of every font in your document.
You are not assigning the right attribute here:
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
====> <item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>
The attribute you need to use is:
android:buttonStyle
I propose the following change:
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:buttonStyle">@style/MyApp.BorderlessButton</item>
</style>
Why:
borderlessButtonStyle
is a conveniently defined style. But it isn't currently wired to any of the default attributes - in this case, buttonStyle
. You still need to assign it.
I can't figure out why the background
and textAllCaps
attributes come into effect. Posting your dialog's/alert dialog's xml might help. Also, how have you defined the string - "i agree" or "I AGREE"?
A buttons in a AlertDialog
use the android:buttonBarButtonStyle
in Holo. Override that attribute in your themes/styles and set the android:minHeight="0dp"
to wrap the content, or of course your can provider your own height.
Correction: I mis-read the title. You of course can set the android:textSize="32sp"
on that same style to change the text size.
Here is the layout for it from the framework:
<LinearLayout android:id="@+id/buttonPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/alert_dialog_button_bar_height"
android:orientation="vertical"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="beginning"
android:dividerPadding="0dip">
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layoutDirection="locale"
android:measureWithLargestChild="true">
<Button android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:layout_weight="1"
android:maxLines="2"
style="?android:attr/buttonBarButtonStyle"
android:textSize="14sp"
android:minHeight="@dimen/alert_dialog_button_bar_height"
android:layout_height="wrap_content" />
<Button android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:maxLines="2"
style="?android:attr/buttonBarButtonStyle"
android:textSize="14sp"
android:minHeight="@dimen/alert_dialog_button_bar_height"
android:layout_height="wrap_content" />
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_gravity="end"
android:layout_weight="1"
android:maxLines="2"
android:minHeight="@dimen/alert_dialog_button_bar_height"
style="?android:attr/buttonBarButtonStyle"
android:textSize="14sp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With