How to achieve automatic width of Button in Android layout -
i have few button listed vertically , need of them have same width, display text inside.
basically need width of them wrapped width of largest one.
hope explained well.
now... have 1 layout working on samsung galaxy s2 (4.1.2), on friend's phone - samsung gt-n7100 (note2) , android 4.4.2 - not working - text not displayed in button.
this layout:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:text="word" android:layout_width="wrap_content" android:layout_height="48dp" android:textsize="30sp" android:gravity="center" android:layout_centerhorizontal="true" android:id="@+id/word"/> <textview android:text="14/36\nm: 1" android:layout_width="fill_parent" android:layout_height="80dp" android:id="@+id/score" android:layout_torightof="@+id/word" android:gravity="right|center" android:paddingright="10dp"/> <linearlayout android:layout_centerinparent="true" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/adapter"> <button android:text="1" android:layout_width="match_parent" android:layout_height="48dp" android:id="@+id/opt1"/> <button android:text="2" android:layout_width="match_parent" android:layout_height="48dp" android:id="@+id/opt2" /> <button android:text="3" android:layout_width="match_parent" android:layout_height="48dp" android:id="@+id/opt3" /> <button android:text="4" android:layout_width="match_parent" android:layout_height="48dp" android:id="@+id/opt4" /> <button android:text="5" android:layout_width="match_parent" android:layout_height="48dp" android:id="@+id/opt5" /> </linearlayout> <button android:text="next" android:layout_width="match_parent" android:layout_height="48dp" android:layout_alignparentbottom="true" android:id="@+id/next"/> </relativelayout>
try setting android.width="auto"
Comments
Post a Comment