【问题标题】:Customize all the dialogs in my application自定义我的应用程序中的所有对话框
【发布时间】:2013-11-14 17:40:42
【问题描述】:

我正在编写一个 Android 应用程序,但我在首选项等中使用的许多对话框的标题在一些较小的屏幕设备上太长了。这会导致文本被裁剪,看起来不太好。

目前我的应用程序没有定义它自己的主题,但我认为我的问题的解决方案是创建一个扩展 @android:style/Theme 的自定义主题,在该主题中我将覆盖 textSize对话框窗口标题。

我对主题和样式非常陌生,不知道如何定义扩展默认主题并仅更改一种样式的主题。

提前致谢 克雷格

【问题讨论】:

    标签: android android-theme android-styles


    【解决方案1】:

    您可以创建自己的对话框,而不是更改主题。这可能比找到更正 DialogTitle 的特定样式更简单。

    public Dialog createDialogShowMyOrder(String title, String message){
        LayoutInflater inflater = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE );
        final View inflator = inflater.inflate(R.layout.YOUR_XML_FILE, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
    
        TextView tit = (TextView)inflator.findViewById(R.id.TITLE_IN_XML);
        TextView mes = (TextView)inflator.findViewById(R.id.MESSAGE_IN_XML);
        tit.setText(title);
        mes.setText(message);
        builder.setView(inflator);
    
        return builder.create();
    }
    

    【讨论】:

    • 这并不能解决我的问题,因为我在整个应用程序中使用 android.preference.DialogPreference 并在需要时创建对话框。我无法更改 DialogPreference 创建的对话框的标题格式
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多