Here I am providing a way to create a text view programmatically with required attributes. Please check and let me know if you have any query for me.
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lparams .gravity = Gravity.CENTER;
TextView tv = new TextView(Myclass.this);
tv.setLayoutParams(lparams );
tv.setText(text + "");
tv.setTextSize(22);
tv.setPadding(5, 5, 5, 5);
// tv.setBackgroundColor(R.drawable.btn_gray_pressed);
tv.setGravity(Gravity.CENTER);
layout.addView(tvdate);//add to your main view
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lparams .gravity = Gravity.CENTER;
TextView tv = new TextView(Myclass.this);
tv.setLayoutParams(lparams );
tv.setText(text + "");
tv.setTextSize(22);
tv.setPadding(5, 5, 5, 5);
// tv.setBackgroundColor(R.drawable.btn_gray_pressed);
tv.setGravity(Gravity.CENTER);
layout.addView(tvdate);//add to your main view
0 comments:
Post a Comment