Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何更改对话框首选项消息的文本大小?_Android_Preferences - Fatal编程技术网

Android 如何更改对话框首选项消息的文本大小?

Android 如何更改对话框首选项消息的文本大小?,android,preferences,Android,Preferences,我有一个扩展了EditTextPreference的类,我在自己的布局中使用它,例如: <com.app.MyEditTextPreference android:key="@string/key" android:title="@string/title" android:summary="@string/summary" android:dialogTitle="@string/title" and

我有一个扩展了
EditTextPreference
的类,我在自己的布局中使用它,例如:

    <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"/>
但是,当显示“首选项”对话框时,消息的大小与我在样式中定义的大小不同

那么如何正确设置对话框消息的文本大小呢

编辑

我从sdk复制了对话框布局:


但是,我在
android:id=“@+android:id/edittext\u container”
行上得到一个生成错误
资源不是公共的

如果我将其更改为
“@*android:id/edittext\u container”
,则编辑文本不再可见


有没有更简单的方法来更改邮件的文本大小?

首先在layout文件夹中创建新的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" />

我最终通过以下方式更改了邮件文本大小:

a) 将
线性布局
的id更改为:
@+id/edittext\u容器
,以及

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);
    }
}
这很好,显然是一个有效的答案,但更简单的解决方案是通过主题更改消息文本大小

<?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();
@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);
    }
}