java - Full width android textView -


i new android , developing card making application. want add feature in app enables user apply background color textview full width. need below image: enter image description here

this works fine when text length long but, when text contains more 1 line , not in full width, becomes below image:

enter image description here

i need result same first image no matter how long text is. in textview have used wrap_content height width. need apply background textview in full display width if textview letter only. hope clear. thanks

try set textview width match_parent.

android:layout_width :-> specifies basic width of view.

sample code

<textview      android:layout_width="match_parent"  android:layout_height="wrap_content" /> 

or set layoutparams of textview programatically this

layoutparams my_params = new linearlayout.layoutparams(layoutparams.match_parent, layoutparams.wrap_content, 1f);     textview.setlayoutparams(my_params); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -