我正在处理一种进度屏幕,但我在外观方面遇到了麻烦。
这是我的代码:
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;
}
我将进度和文本视图的样式设置为大,但它们显示得非常小。
有任何想法吗?