开发者

How to make TextView the same size regardless of the texts inside

i have 1 linear layout, inside it i have 1 table layout and inside it i have 2 table rows and inside each row i have 2 textviews. Each textwiev has a background in 9.png.format to look like a button.

How do i make those textviews all the same size regardles of its texts, making the backgroung images the same size too?

This is what i allready made:

<LinearLayout android:layout_height="fill_parent"
              android:gravity="bottom" 
              android:layout_width="fill_parent"
              android:layout_weight="2">
<TableLayout android:layout_height="wrap_content"
             android:layout_width="fill_parent"
             android:stretchColumns="0 1">
             <TableRow android:layout_width="fill_parent"
                       android:layout_height="fill_parent"
                       android:layout_weight="1"
                       android:padding="2dp">
                       <TextView android:layout_width="fill_parent"
                                  android:layout_height="fill_parent"
                                  android:background="@drawable/answer_small_off"
                                  android:layout_weight="1"
                                  android:text="@string/hello" 
                                  android:gravity="center" 
                                  android:id="@+id/main_text_answer1" 
                                  android:lines="3" 
                                  android:maxLines="3"
                                  android:textSize="10dp" android:minLines="3" android:minEms="20" android:maxEms="20" android:ems="20">
                        </TextView>
                        <TextView android:layout_width="fill_parent"
                                  android:layout_height="fill_parent"
                                  android:background="@drawable/answer_small_off"
                                  android:layout_weight="1"
                                  android:text="@string/hello" 
                                  android:gravity="center" 
                                  android:id="@+id/main_text_answer2" 
                                  android:lines="3" 
                                  开发者_C百科android:maxLines="3"
                                  android:textSize="10dp">
                        </TextView>
             </TableRow>
             <TableRow android:layout_width="fill_parent"
                       android:layout_height="wrap_content"
                       android:layout_weight="1"
                       android:padding="2dp">
                       <TextView android:layout_width="fill_parent"
                                 android:layout_height="fill_parent"
                                 android:background="@drawable/answer_small_off"
                                 android:layout_weight="1"
                                 android:text="@string/hello" 
                                 android:gravity="center" 
                                 android:id="@+id/main_text_answer3" 
                                 android:lines="3" 
                                 android:maxLines="3"
                                 android:textSize="10dp">
                        </TextView>
                       <TextView  android:layout_width="fill_parent"
                                  android:layout_height="fill_parent"
                                  android:background="@drawable/answer_small_off"
                                  android:layout_weight="1"
                                  android:text="@string/hello" 
                                  android:gravity="center" 
                                  android:id="@+id/main_text_answer4" 
                                  android:lines="3" 
                                  android:maxLines="3"
                                  android:textSize="10dp">
                        </TextView>

             </TableRow>
             </TableLayout>
             </LinearLayout>

btw. this is just a part of the screen, but the rest is not important i think


All you need to do is change the Layout_height and Layout_width like this:

                   <TextView android:layout_width="149dp"
                              android:layout_height="50dp"
                              android:background="@drawable/answer_small_off"
                              android:layout_weight="1"
                              android:text="@string/hello" 
                              android:gravity="center" 
                              android:id="@+id/main_text_answer1" 
                              android:lines="3" 
                              android:maxLines="3"
                              android:textSize="10dp" android:minLines="3" android:minEms="20" android:maxEms="20" android:ems="20">
                   </TextView>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜