gpt4 book ai didi

android - 圆形图像按钮android

转载 作者:太空宇宙 更新时间:2023-11-03 12:08:16 25 4
gpt4 key购买 nike

我有一个图片中的图像按钮。我希望它周围的红色空间(它将是透明的,只是给出红色来标识空间)将不可点击。是否可以 ?我尝试了不同的代码,比如通过 xml 或一些圆形的 imageview 代码,但没有任何帮助..

enter image description here

最佳答案

无需计算任何东西,您唯一需要做的就是在按钮模板 xml(可绘制对象)中定义 imageButton 的形状。

因此在您的 UI 布局 xml 文件中,ImageButton 可能会这样描述

<ImageButton
android:id="@+id/button"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/yourIcon"
android:background="@drawable/button" <!-- PATTERN!! -->
android:contentDescription="obrazek"
android:padding="5dp"
android:layout_margin="1dp"
android:onClick="onClick"/>

在你的模式文件中声明 shape="oval" 即像这样

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<gradient
android:startColor="#50d050"
android:endColor="#008000"
android:angle="270"/>

<stroke
android:width="1px"
android:color="#000000"/>

</shape>

再简单不过了。 :D

关于android - 圆形图像按钮android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21397115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com