首页 > 解决方案 > 如何隐藏 Button 和 TextView 的边框?

问题描述

我创建了用于输入数量的按钮,效果很好,但是 Button 和 TextView 周围有边框。这个边框怎么去掉?

<LinearLayout
            android:layout_width="90dp"
            android:layout_height="33dp"
            android:layout_alignBottom="@+id/BasketGoodsIcon"
            android:layout_marginStart="7dp"
            android:layout_marginBottom="7dp"
            android:layout_toEndOf="@+id/BasketGoodsIcon"
            android:orientation="horizontal">

            <Button
                android:id="@+id/decrement"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:background="@drawable/button_left_round"
                android:padding="0dp"
                android:text="-"
                android:textColor="@color/BasketInputQttyBtnTxtColor"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/display"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:background="@color/BasketInputQttyBtnColor"
                android:gravity="center"
                android:inputType="number"
                android:text="1"
                android:textColor="@android:color/black" />

            <Button
                android:id="@+id/increment"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:background="@drawable/button_right_round"
                android:padding="0dp"
                android:text="+"
                android:textColor="@color/BasketInputQttyBtnTxtColor" />
        </LinearLayout>

在此处输入图像描述

我希望这三个元素看起来像一个元素。

标签: androidxmlandroid-studioandroid-layout

解决方案


在你的背景 drawable.xml 使边框颜色透明

<stroke
        android:color="#0000" />

推荐阅读