【问题标题】:EditText change size if I press enter or close the keyboard如果我按 Enter 或关闭键盘,EditText 会更改大小
【发布时间】:2020-03-07 17:49:01
【问题描述】:

如果我在 EditText 中写入数字,则大小不会改变 Pic1,但如果我按下回车键或关闭键盘,EditText 会改变大小。 Pic2 是否可以关闭它? (所有的 TableRows 和 EditTexts 都是一样的,只是列不同)

    ...
<TableLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:padding="6dp"
      android:stretchColumns="*">

  <TableRow
     android:layout_width="match_parent"
     android:layout_height="match_parent">
       <EditText
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_column="1"
                android:background="@drawable/background"
                android:inputType="number"
                android:maxLength="3"
                android:textAlignment="center"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
               ...

【问题讨论】:

    标签: java android layout android-edittext


    【解决方案1】:

    您需要为表格布局中的每个视图设置 android:layout_width="0dp" 和 android:layout_weight="1"

    【讨论】:

      猜你喜欢
      • 2012-03-11
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 2011-08-24
      • 1970-01-01
      • 2019-06-04
      • 1970-01-01
      相关资源
      最近更新 更多