Android – how do I change the text size of dialog preferences messages?
I have a class that extends edittextpreference. 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 app theme inherits from theme.appcompat.light.darkactionbar. I changed the value of text size:
<style name="TextAppearance.Small">
<item name="android:textSize">18sp</item> <!-- was 14sp -->
</style>
However, when the preferences dialog box is displayed, the size of the message is different from the size I defined in my style
So how to correctly set the text size of dialog messages?
edit
I copied the dialog layout from the 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 got a build error resource that is not public Android: id = "@ Android: ID / edittext_container"
If I change it to "@ * Android: ID / edittext_container", the edited text will no longer be visible
Is there a simpler way to change the text size of a message?
resolvent:
First, create a new XML file named cus. XML in the layout folder. It needs to set the view of the dialog box at run time
<?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" />
When you need a dialog: This is the dialog code:
Dialog d=new Dialog(getActivity());
d.setTitle("Image Title");
d.setContentView(R.layout.cus);
d.show();