【问题标题】:change the colour and font of text of title in dialog box更改对话框中标题文本的颜色和字体
【发布时间】:2014-02-13 07:36:17
【问题描述】:

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

这是我的代码,

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();

            }
        });

谁能帮帮我? 谢谢你。

【问题讨论】:

    标签: android css dialog


    【解决方案1】:

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

    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/titleDividerandroid.R.id.title 在 SDK 文件夹的 alert_dialog.xml 中找到的标识符中

    【讨论】:

      【解决方案2】:

      您应该使用自定义视图作为对话框的标题,也许此链接对您有帮助 how to include custom title view with in AlertDialog in android?

      【讨论】:

        【解决方案3】:

        试试这个方法

        private String HALLOWEEN_ORANGE = "#FF7F27";
        
        AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Message").show();
        
        setTitle("Title").
        setTitleColor(HALLOWEEN_ORANGE).
        
        setDividerColor(HALLOWEEN_ORANGE).
        
        TextView textView = (TextView) dialog.findViewById(android.R.id.message);
        textView.setTextSize(10);//to change font size
        textView.setTextColor(Color.RED); // to change color
        //to change font family
        Typeface face = Typeface.createFromAsset(getAssets(),"font/fontFileName.ttf");
        textView.setTypeface(face);
        

        【讨论】:

        • 我只想更改标题的字体和颜色,而不是消息!!!!!!! “N.G.GROUP”在我的帖子中看到它
        猜你喜欢
        • 2014-07-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-01
        • 2016-05-31
        • 2015-10-29
        • 2018-01-23
        相关资源
        最近更新 更多