例如:
TextView textView = new TextView(PhotoActivity.this);
textView.setText("Photo not found.");
如何设置样式?
textView.set... ???
谢谢大家,我找到了所需的解决方案。
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT, AbsListView.LayoutParams.FILL_PARENT);
params.weight = 1.0f;
params.gravity = Gravity.CENTER;
TextView textView = new TextView(PhotoActivity.this);
textView.setText("Photo not found.");
textView.setTextColor(Color.WHITE);
textView.setLayoutParams(params);
作为一种替代方法:
textView.setGravity(Gravity.CENTER);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句