2012-09-13 66 views
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; 
} 

我設置的進度和TextView的大風格,但他們確實顯示小。
任何想法?

+0

如何在程序中添加樣式http://stackoverflow.com/q/11507476/1012284 –

回答

1

您正在使用錯誤的功能。

實際上,您在構造函數中設置樣式。

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