android - 在对话框中更改标题文本的颜色和字体

标签 android css dialog

我想更改对话框中标题的字体和颜色,我想更改字体、大小和颜色,我该怎么办?

这是我的代码,

ivworknggroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                final Dialog dialog = new Dialog(Ourwork.this);
                dialog.setContentView(R.layout.nggroup);
                dialog.setTitle("N.G.GROUP");

                TextView tvnggroup1 = (TextView) dialog.findViewById(R.id.tvnggroup1);

                TextView tvnggroup2 =(TextView)dialog.findViewById(R.id.tvnggroup2);

                Typeface typeFace1 =  Typeface.createFromAsset(getAssets(),"fonts/antennalight.ttf");
                tvnggroup1.setTypeface(typeFace1);
                Typeface typeFace =  Typeface.createFromAsset(getAssets(),"fonts/antennabold.ttf");
                tvnggroup2.setTypeface(typeFace);

                tvnggroup2.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        // TODO Auto-generated method stub
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.nggroupindia.com/"));
                        startActivity(browserIntent);
                    }
                });
                dialog.show();

            }
        });

谁能帮帮我? 谢谢你。

最佳答案

好吧,我曾经遇到过类似的情况,但这就是为我解决的问题。

Dialog sortDialog = new Dialog(getApplicationContext());
                sortDialog.setContentView(R.layout.adtype_alertdialog);
                sortDialog.setTitle("N.G.GROUP");
                int dividerId = sortDialog
                        .getContext()
                        .getResources()
                        .getIdentifier("android:id/titleDivider", null,
                                null);
                if (dividerId != 0) {
                    View divider = sortDialog.findViewById(dividerId);
                    divider.setBackgroundColor(getResources().getColor(
                            R.color.yellow));
                }
                TextView tv = (TextView) sortDialog
                        .findViewById(android.R.id.title);
                if (tv != null) {
                    tv.setTextColor(getResources().getColor(R.color.yellow));
                }
                sortDialog.show();

android:id/titleDivider & android.R.id.title 在您的 SDK 文件夹的 alert_dialog.xml 中找到的标识符

关于android - 在对话框中更改标题文本的颜色和字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21747915/

相关文章:

android - 如何在没有 Activity 的情况下在服务中显示文本或图形?

css - 用于 NetBeans IDE 的代码 unminify 插件

java - 无法在按钮单击 Android 上显示警报对话框

java - 如何设置倒计时时间格式

android - 将xml中相邻 View 的id传递给自定义 View 并在自定义 View 的构造函数中检索它

CSS div 溢出。 (调整浏览器大小时)

css - 闪烁的虚线链接

c# - 寻找 .NET C# 每日提示组件

c# - Ookii VistaFolderBrowserDialog 并获取选定的文件夹

java - Listview 不再向其中的 spinner 注册 itemClickEvent