How to resize dialog preference message text?

I have a class that extends EditTextPreference, and I use it in my own layout, for example:

    <com.app.MyEditTextPreference
        android:key="@string/key"
        android:title="@string/title"
        android:summary="@string/summary"
        android:dialogTitle="@string/title"
        android:dialogMessage="@string/message"
        android:layout="@layout/preference_edittext"/>

My application theme inherits from Theme.AppCompat.Light.DarkActionBar, and I changed the text size values:

<style name="TextAppearance.Small">
    <item name="android:textSize">18sp</item> <!-- was 14sp -->
</style>

However, when the settings dialog is displayed, the message size is different from the one I defined in my style.

So, how to set the size of the text of the dialog message?

EDIT

I copied the dialog layout from sdk:

<LinearLayout
    android:id="@+android:id/edittext_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="20dp"
    android:orientation="vertical">

    <TextView
        android:id="@android:id/message"
        android:layout_marginBottom="48dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        android:textColor="?android:attr/textColorSecondary"
        style="@style/TextAppearance.Small" />

</LinearLayout>

However, I get a build error Resource is not publicin the line android:id="@+android:id/edittext_container".

And if I change it to "@*android:id/edittext_container", the edit text is no longer displayed.

Is there an easy way to just change the message text?

+4
2

:

a) LinearLayout : @+id/edittext_container

b) , EditTextPreference:

@Override
protected void onAddEditTextToDialogView(View dialogView, EditText editText) {
    ViewGroup container = (ViewGroup) dialogView
            .findViewById(R.id.edittext_container);

    if (container != null) {
        container.addView(editText, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
}

, , , .

0

xml cus.xml . .

<?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Enter Name :"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="18dp" />


<EditText
    android:id="@+id/editText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textSize="18dp" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:textSize="18dp" />

: :

Dialog d=new Dialog(getActivity());
                d.setTitle("Image Title");
                d.setContentView(R.layout.cus);
                d.show();
0

Source: https://habr.com/ru/post/1619816/


All Articles