是否有可能改变进度对话框的消息或微调的位置? [英] Is it possible to alter progress dialog's message or spinner position?

查看:152
本文介绍了是否有可能改变进度对话框的消息或微调的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上希望把进度对话框进度条(微调)之前消息文本,以看起来像小吃店。

I basically want to put message text before progress bar (spinner) in progress dialog in order to look like snackbar.

推荐答案

有可能做到这一点,我不是在此刻思考的一些更简单的方法,但你可以重写 ProgressDialog 的onCreate()方法,和小提琴的布局编程。例如:

There might be some easier way to do this that I'm not thinking of at the moment, but you could override the ProgressDialog's onCreate() method, and fiddle with the layout programmatically. For example:

ProgressDialog pd = new ProgressDialog(this) {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ProgressBar progress = (ProgressBar) findViewById(android.R.id.progress);
        LinearLayout bodyLayout = (LinearLayout) progress.getParent();
        TextView messageView = (TextView) bodyLayout.getChildAt(1);

        LinearLayout.LayoutParams llp =
            (LinearLayout.LayoutParams) messageView.getLayoutParams();
        llp.width = 0;
        llp.weight = 1;

        bodyLayout.removeAllViews();
        bodyLayout.addView(messageView, llp);
        bodyLayout.addView(progress);
    }
};

pd.setMessage("Testing...");
pd.show();

我不得不通过源代码的版本快看,我认为这应该为pretty工作的'时间都多。

I had a quick look through the source versions, and I think this should work for pretty much all of 'em.

这篇关于是否有可能改变进度对话框的消息或微调的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆