• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Text alignment doesn't work

  • Thread starter Thread starter Deleted User
  • Start date Start date
D

Deleted User

Guest
Dear all,

I am trying to align text in a TextView but the following code doesn't do it.

public class LearnActivity extends Activity
{
@override
protected void onCreate(Bundle savedInstanceState)
{
LinearLayout layout;
LinearLayout.LayoutParams linLayoutParam;
TextView text;

super.onCreate(savedInstanceState);

layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
linLayoutParam = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
setContentView(layout, linLayoutParam);

text = new TextView(this);
text.setText("this is made very long to text textLayout attribute, just to make sure that it works.");
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
layout.addView(text);
}
}


Thank you for help
 
Could someone reply to my post.

I am new to the forum. I cannot see the number of viewers? Should I activate something?
 
Back
Top Bottom