在我的代码中,我想在 CENTER 中设置文本视图,请参阅此代码,告诉我如何设置
我尝试编辑此代码,但日期文本视图未出现 CENTER 请告诉更改
LinearLayout ll2=new LinearLayout(ctx);
LayoutParams lp3=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ll2.setLayoutParams(lp3);
ll2.setOrientation(LinearLayout.VERTICAL);
LayoutParams lp2=null;
LinearLayout ll4=new LinearLayout(ctx);
lp2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
TextView tv2=new TextView(ctx);
lp2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT);
tv2.setLayoutParams(lp2);
tv2.setText("MESSAGE");
tv2.setBackgroundResource(R.drawable.rec);
tv2.setTextSize(14);
tv2.setTextColor(Color.parseColor("#5A3084"));
if(sm!=null && sm.message!=null)
tv2.setText(sm.message.toString());
tv2.setGravity(Gravity.LEFT);
tv2.setPadding(10, 0, 10, 0);
TextView tv0=new TextView(ctx);
lp2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
tv0.setLayoutParams(lp2);
tv0.setText("Alertdate :");
tv0.setBackgroundResource(R.drawable.rec1);
tv0.setTextColor(Color.parseColor("#38385E"));
tv0.setGravity(Gravity.CENTER_VERTICAL);
tv0.setTextSize(12);
if(sm!=null && sm.alertdate!=null)
tv0.setText(sm.alertdate+"");