样式外观不起作用

时间:2012-09-13 07:54:19

标签: android

我正在制作一个进度屏幕,但我遇到了问题。

这是我的代码:

    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;
}

我将进度和textview的样式设置为大,但它们显示的很小 有任何想法吗?

1 个答案:

答案 0 :(得分:1)

你使用了错误的功能。

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

ProgressBar circle = new ProgressBar(this, null, 
                               android.R.attr.progressBarStyleLarge);