【问题标题】:TableLayout layout_column causes error for API level < 24TableLayout layout_column 导致 API 级别 < 24 的错误
【发布时间】:2017-11-08 22:24:19
【问题描述】:

应用程序在打开之前重新启动。我检查了我的java代码,没关系。并且应用程序在高于 7 的 android 中运行。这是我的 UI XML:

<TableRow
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">
    <Button
        android:id="@+id/button_on"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="\u23FB"
        android:background="@drawable/button_shape"
        android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
        android:backgroundTint="@color/colorButtonOpEnabled"
        android:textColor="#fff"
        android:layout_weight="1"
        android:textSize="20sp"
        android:layout_margin="2dp"
        />
    <Button
        android:id="@+id/button_clear"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="CE"
        android:background="@drawable/button_shape"
        android:backgroundTint="@color/colorButtonCEDisabled"
        android:textColor="@color/colorButtonTextDisabled"
        android:layout_weight="1"
        android:textSize="20sp"
        android:enabled="false"
        android:layout_margin="2dp"/>
    <Button
        android:id="@+id/button_correct"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="CORRECT"
        android:background="@drawable/button_shape"
        android:backgroundTint="@color/colorButtonOpDisabled"
        android:textColor="@color/colorButtonTextDisabled"
        android:layout_column="3"
        android:layout_span="2"
        android:layout_weight="2"
        android:textSize="20sp"
        android:enabled="false"
        android:layout_margin="2dp"/>
</TableRow>

当我删除此行或将其更改为 2 时,它可以工作(我分配 3 以在 button_clear 和 button_correct 之间创建一个空白区域):

android:layout_column="3"

这是应用程序的屏幕截图:

【问题讨论】:

  • 如果您将实际的空视图添加到第 3 列而不是使用 android:layout_column="3" 会有帮助吗?
  • 是的,没问题。这实际上很简单。谢谢。
  • 我将其发布为您的答案,以便您标记为解决方案;-)

标签: android android-layout tablelayout


【解决方案1】:

在第三列添加一个实际的空视图,而不是使用android:layout_column="3"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2012-05-11
    相关资源
    最近更新 更多