简体   繁体   English

如何在Android中对齐TextView

[英]How to align TextView in android

I am adding Linearlayout dynamically and adding 3 TextView getting the content from webservices for text view if the content of 3 text size is larger it will display in the end of next line .i want display in start line how can i do? 我正在动态添加Linearlayout并添加3 TextViewwebservices获取文本视图的内容,如果3文本大小的内容较大,它将显示在下一行的末尾。我想在起始行中显示怎么办?

Thanks 谢谢

To align your Text inside a specific TextView: 在特定的TextView中对齐文本:

    Textview t = (Textview) findViewbyid(R.id.yourView); //refernce to your View
    t.setGravity(Gravity.RIGHT); //or any align you want
    t.setText("String text or long string");
TextView   header_text;
header_text = (TextView) findViewById(R.id.header_text1);   
header_text.setSingleLine();

尝试使用android:gravity =“ left”或alignParent =“ left”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM