【问题标题】:I am trying to place a button at the bottom of LinearLayout. But it's not showing我试图在 LinearLayout 的底部放置一个按钮。但它没有显示
【发布时间】:2021-02-27 15:18:48
【问题描述】:
<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"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Quantity" />

    <TextView
        android:id="@+id/quantity_text_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="0"
        android:textColor="@color/black"
        android:textSize="16sp" />

    <Button
        android:id="@+id/button_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=" Order" />

</LinearLayout>

我是 Android 新手。我正在 Udacity 学习 Android。但是课程已经很老了,以至于发生了一些错误。我无法处理这些错误。

【问题讨论】:

    标签: java android xml android-layout


    【解决方案1】:

    quantity_text_view 的 layout_height 从 match_parent 更改为 wrap_content

    <TextView
            android:id="@+id/quantity_text_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="0"
            android:textColor="@color/black"
            android:textSize="16sp" />
    

    或者,TextView 应该占据第一个 TextView 之后的剩余高度。

    【讨论】:

      猜你喜欢
      • 2020-11-09
      • 1970-01-01
      • 2019-11-27
      • 2022-01-19
      • 2013-01-24
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多