0

我正在处理一种进度屏幕,但我在外观方面遇到了麻烦。

这是我的代码:

    LinearLayout progressLayout = new LinearLayout(this);
    progressLayout.setOrientation(LinearLayout.VERTICAL);
    progressLayout.setGravity(Gravity.CENTER);

    LayoutParams layoutParams = new LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.FILL_PARENT);

    progressLayout.setLayoutParams(layoutParams);

    LayoutParams titelParams = new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
    titelParams.setMargins(0, 0, 0, pixelsToDIP(15));

    TextView t = new TextView(this);
    t.setText("Zorgdossier wordt geladen");
    t.setTextAppearance(this, android.R.attr.textAppearanceLarge);
    t.setLayoutParams(titelParams);

    ProgressBar circle = new ProgressBar(this);
    circle.setScrollBarStyle(android.R.attr.progressBarStyleLarge);
    circle.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

    progressLayout.addView(t);
    progressLayout.addView(circle);

    this.setContentView(progressLayout);

}

private int pixelsToDIP(int pixel) {
    float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            pixel, this.getResources().getDisplayMetrics());

    return (int) pixels;
}

我将进度和文本视图的样式设置为大,但它们显示得非常小。
有任何想法吗?

4

1 回答 1

1

您使用了错误的功能。

实际上,您在构造函数中设置了样式。

ProgressBar circle = new ProgressBar(this, null, 
                               android.R.attr.progressBarStyleLarge);
于 2012-09-13T08:06:41.260 回答