похоже, что вы пытаетесь сделать кнопку в таблице, как в XML ???
не знаю, если это может помочь вам, но когда я пытаюсь сделать то же точную ширину я использовать это ...
здесь `s объяснение
создать 1 линейную компоновку с вертикальной ориентацией (поэтому, каждый раз, когда вы добавляете новый элемент, он будет помещаться вниз)
внутри него, вставить линейную компоновку с горизонтальной ориентацией ... (вставить столько строк, которые вы хотите, в вашем случае похоже, что вам нужно 5 линейных макетов с горизонтальной ориентация)
af ter, вставьте кнопку/текст в линейную компоновку (горизонтальная ориентация), поэтому ваша кнопка/текст будет размещаться горизонтально.
Если вы хотите изменить строку, просто вставьте кнопку/текст в другую линейную компоновку (горизонтальная ориентация).
после вставки все, установить линейную схему (горизонтальное значение) с этим кодом
android:weightSum="5"
почему 5? потому что в вашем случае, сделайте 5 столбцов. и не забудьте установить width = fill parent.
после этого установить кнопку/TextView внутри LinearLayout (по горизонтали) с дополнительным этим кодом
android:layout_weight="1"
и не забудьте изменить ширину с заполнением родителем.
с этим, я могу сделать точную ширину в каждом ряду.на следующем шаге вы можете установить маржу, чтобы ваша кнопка/текст выглядели хорошо.
надеюсь, что это может помочь вам ...
================================== === здесь `s код, если вы путаете с моим объяснением
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.tes.MainActivity"
tools:ignore="MergeRootFrame" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="5" >
<Button
android:id="@+id/Button22"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button21"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button24"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button23"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button20"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="5" >
<Button
android:id="@+id/Button17"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button16"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button19"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button18"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button15"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="5" >
<Button
android:id="@+id/Button12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button14"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="5" >
<Button
android:id="@+id/Button07"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button06"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button09"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button08"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button05"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="5">
<Button
android:id="@+id/Button04"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button03"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_weight="1"/>
</LinearLayout>
Добавьте код XML, который вы должны попробовать – MilapTank
и можно установить размер кнопки фиксированного вместо wrap_content – KOTIOS
пытаются использовать [GridView ] (http://developer.android.com/guide/topics/ui/layout/gridview.html) – kId