【问题标题】:How to maximize button width in Android?如何在Android中最大化按钮宽度?
【发布时间】:2014-07-26 03:29:24
【问题描述】:

无论智能手机或平板电脑的屏幕尺寸如何,如何确保始终最大化按钮宽度?目的是始终保证MaxWidth Button = MaxWidth Smartphone

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableRow
        android:layout_marginTop="20dip">

        <Button
            android:id="@+id/submit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_span="20"
            android:clickable="true"
            android:text="@string/submit" >
        </Button>
    </TableRow>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="center"
        android:orientation="horizontal"
        android:text="@string/version"
        android:textSize="15sp" />
</TableLayout>

【问题讨论】:

标签: android


【解决方案1】:

将按钮的 layout_weight 设置为 1。然后它将占据表格行中的所有可用空间。

【讨论】:

    【解决方案2】:

    像这样替换按钮;

    <Button
            android:id="@+id/submit"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_span="20"
            android:clickable="true"
            android:text="@string/submit" >
    

    【讨论】:

      猜你喜欢
      • 2020-05-29
      • 1970-01-01
      • 2017-02-13
      • 2020-02-16
      • 2021-11-07
      • 2013-07-21
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多