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.
我有1个线性布局,里面我有1个表格布局,里面我有2个表格行,每行内部我有2个textviews。每个textwiev都有9.png.format背景,看起来像一个按钮。
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"
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
顺便说一句。这只是屏幕的一部分,但其余的并不重要
1 个解决方案
#1
4
All you need to do is change the Layout_height and Layout_width like this:
您需要做的就是更改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
4
All you need to do is change the Layout_height and Layout_width like this:
您需要做的就是更改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>