2011-10-06 13 views
9

私はそれの中に1つのテーブルレイアウトがあり、それの中に2テーブルの行があり、各行の中に2つのtextviewsがあります。各textwievはボタンのように見える9.png.formatの背景を持っています。どのようにTextView内のテキストに関係なく同じサイズを作る

これらのテキストビューをテキストのすべてのサイズに合わせると、バックグラウンドイメージのサイズが同じになります。

これは私が出回っ作ったものである。ところで

<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" 
            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> 

。これは、画面のほんの一部ですが、残りは重要ではありません私はあなたがする必要がある

+0

CRO、 は私が持っていたように見えます同様のケースと私自身でそれを解決した[回答](http://stackoverflow.com/questions/7698397/textview-height-increase-when-decreasing-font-size/7707447#7707447) –

答えて

4

すべてがこのようLayout_heightとLayout_widthを変更だと思う:

    <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> 
+1

しかし、私はこれを作っている複数のスクリーンタイプのアプリ、私はクイズアプリを作っていて、それは答えボタンなので、これは他のスクリーンで問題を起こさないでしょうか?= –

+0

そうでなければfill parentを使うことができます:android:layout_width = "FILL_PARENT" –

+2

OK、android:minEms = "20" android:maxEms = "20" android:ems = "20" 、ビューの線の線の高さはまだ変化しています –

関連する問題