2014-02-12 3 views
1

Я делаю калькулятор, но внутри рамки, это не подходит.Как поместить «Кнопки» в рамку с помощью «строки таблицы»?

Я использую «Табличный макет» внутри него.

но это показывает это.

enter image description here

В то время как я хотел бы сделать так.

enter image description here

пожалуйста, помогите, как исправить мою кнопку правильную внутреннюю рамку? Благодарю.

Вот мой исходный код для «кнопки».

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     android:background="#cccccc" 
     android:padding="15dp"/> 

    <TableLayout 
     android:id="@+id/tableID" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp"> 

     <TableRow> 
      <Button 
       android:id="@+id/btn7" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="7"/> 

      <Button 
       android:id="@+id/btn8" 
       android:text="8" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1"/> 

      <Button 
       android:id="@+id/btn9" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="9" 
       android:layout_weight="1"/> 

      <Button 
       android:id="@+id/btnDivide" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="÷" 
       android:layout_weight="1"/>  
     </TableRow> 

     <TableRow> 

      <Button 
       android:id="@+id/btn4" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="4" 
       android:layout_weight="1"/> 

      <Button 
       android:id="@+id/btn5" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="5" 
       android:weight="1"/> 

      <Button 
       android:id="@+id/btn6" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="6" 
       android:weight="1"/> 

      <Button 
       android:id="@+id/btn7" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="7" 
       android:weight="1"/> 

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

ответ

1

В последнем XML 3 кнопки, вы пишете андроида: вес = "1" который будет андроид: layout_weight = "1"

<TableRow> 

     <Button 
      android:id="@+id/btn4" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="4" 
      android:layout_weight="1"/> 

     <Button 
      android:id="@+id/btn5" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="5" 
      android:layout_weight="1"/> 

     <Button 
      android:id="@+id/btn6" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="6" 
      android:layout_weight="1"/> 

     <Button 
      android:id="@+id/btn7" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="7" 
      android:layout_weight="1"/> 

    </TableRow> 
+0

Sh ** т упс извините , thaks .. :) Я забыл это .. –

+1

Тогда примите ответ, человек ... :) –

 Смежные вопросы

  • Нет связанных вопросов^_^