Android按钮拒绝减少表中的大小?

时间:2014-07-13 22:54:44

标签: android xml button

我有一个在桌子上的按钮,但按钮在屏幕上伸展,从而拉伸我的图像,使其变得丑陋。我尝试过wrap_content,fill_parent和match_parent,但它们都给出了相同的结果。这是我的xml。为什么按钮不会减小它的大小???

              <?xml version="1.0" encoding="utf-8"?>
              <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:background="@drawable/bg2"
                    android:orientation="vertical" >


                   <TableRow>
                     <ImageView
                             android:contentDescription="@string/contents"
                             android:id="@+id/imageView1"
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:layout_gravity="center_horizontal|top"
                             android:paddingTop="10dp"
    android:src="@drawable/lesson1" />
  </TableRow>

  <TableRow>

      <TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/alpha"
          android:paddingLeft="15dp"
          android:textAppearance="?android:attr/textAppearanceLarge" />

  </TableRow>


  <TableRow>
        <TextView
          android:id="@+id/textView3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingLeft="15dp"
          android:textStyle="italic"
          android:text="@string/alphanote"
          android:textAppearance="?android:attr/textAppearanceMedium" />

  </TableRow>


  <TableRow>
      <TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/directions2"
          android:paddingLeft="15dp"
          android:textAppearance="?android:attr/textAppearanceMedium" />

  </TableRow>

  <TableRow>

      <Button
          android:id="@+id/Button1"
          android:layout_width="14dp"
          android:background="@drawable/playstart" />

  </TableRow>

  <TableRow>
      <TextView
          android:id="@+id/textView4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/alpha1"
          />

      </TableRow>
        </TableLayout>     
     </ScrollView>

1 个答案:

答案 0 :(得分:0)

如果您只有一列,我不知道为什么您会对TableLayoutTableRow感到烦恼。 TableLayout用于多列表格。

话虽如此,您无法通过任何提及的方法控制TableLayout中列的宽度。相反,请在TableLayout本身上使用android:stretchColumnsandroid:shrinkColumns

我不确定它是否会起作用,因为TableLayout背后的一点是尝试最好地将行填充到表的宽度。您应该将其转换为简单的垂直LinearLayout