Tuesday 30 April 2019

Change text size on the positveButtonText in the EditTextPreference dialog

I cannot figure out how to change the text size on the buttons in the EditTextPreference dialog popup box. I would like all my text throughout my app to be streamlined at 24 sp. This is happening everywhere except this dialog box from the PreferenceScreen. As you can see in the ListPreference I figured out how to hide the positiveButtonText and negativeButtonText.

I would like to do this in the xml, if possible. I also would like to avoid having to create a custom dialog layout. In the EditTextPreference tag I can edit the title and layout in the dialog, I just can't figure out how to "touch" the default buttons.

Here is my pref_connection.xml:

<PreferenceScreen 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:title="Connection">

    <ListPreference
        android:defaultValue="box1"
        android:entries="@array/pref_box_type_list_titles"
        android:entryValues="@array/pref_box_type_list_values"
        android:key="box_types_list"
        android:negativeButtonText="@null"
        android:positiveButtonText="@null"
        android:layout="@layout/preference_screen_layout"
        android:title="@string/pref_title_box_type"/>

    <EditTextPreference
        android:defaultValue="@string/pref_default_internet_addr"
        android:digits="0123456789."
        android:inputType="number|numberDecimal"
        android:key="internet_addr"
        android:selectAllOnFocus="true"                  
        android:singleLine="true"
        android:layout="@layout/preference_screen_layout"
        android:textSize="@dimen/text_size"
        android:title="@string/pref_title_internet_addr"/>
    <...>
</PreferenceScreen>

Here is the layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView android:id="@android:id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/large_margin"
        android:paddingBottom="@dimen/margin"
        android:textSize="@dimen/text_size"/>

    <TextView android:id="@android:id/summary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/large_margin"
        android:textSize="@dimen/text_size"/>

</LinearLayout>

Would like to do something simple like styles:

<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:textSize">24sp</item>
</style>

or utilize dialogLayout inside the EditTextPreference:

android:dialogLayout="@layout/dialogLayout"

But can't seem to get any of those working.

Hopefully screenshots of my app will help with understanding what I'm trying to accomplish.

This shows my Preference screen on the left side. This shows my Preference screen on the left side.

This shows the dialog box that pops up after the EditTextPreference is clicked. The text size on the cancel and ok buttons are what I'm trying to change. See red arrows. The other text in this dialog are controlled by the attributes in the EditTextPreference. This shows the dialog box that pops up after the EditTextPreference is clicked. The text size on the cancel and ok buttons are what I'm trying to change. See red arrows.

Any help would be greatly appreciated.



from Change text size on the positveButtonText in the EditTextPreference dialog

No comments:

Post a Comment