简体   繁体   中英

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?

Thanks

To align your Text inside a specific 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”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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