【发布时间】:2014-07-01 13:15:33
【问题描述】:
您好,我在按钮中覆盖了我的 ImageView,但是当它们彼此如此接近时,您无法辨认出它是按钮,它只是一个大的红色方块。我需要一种快速简便的方法来给我的按钮边框/边缘或其他东西,以便您可以看到不同的按钮。
【问题讨论】:
您好,我在按钮中覆盖了我的 ImageView,但是当它们彼此如此接近时,您无法辨认出它是按钮,它只是一个大的红色方块。我需要一种快速简便的方法来给我的按钮边框/边缘或其他东西,以便您可以看到不同的按钮。
【问题讨论】:
在可绘制资源中创建形状
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#C0213A" />`<!--Background Color-->`
<stroke android:width="2dip" android:color="#C0213A"/> `<!--Border-->`
</shape>
在您的 XML 中
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:background="@drawable/your_shape"> `<!--This is your shape created--`>
【讨论】:
按钮没有边框,但您可以使用 shape 制作带边框的可绘制对象,然后将其作为按钮的背景。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/red" />
<stroke
android:width="1dp"
android:color="@color/black" />
</shape>
【讨论】: