Android形状按钮点击区域

标签 android animation button shapes

我有以下形状

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:angle="360" android:endColor="@color/LightBlue" android:startColor="@color/DarkBlue"/>
    <corners android:topRightRadius="10dp" android:bottomLeftRadius="10dp"/>
</shape>

和这个按钮

<Button android:id="@+id/butLeft" android:layout_width="25dp"
            android:layout_height="@dimen/contentTabHeight" android:background="@drawable/lefttabbackground"
            android:layout_toRightOf="@id/contentLeft"
            android:layout_centerVertical="true"></Button>

现在我要做的是我有一个自定义动画,将 contentleft(linearlayout) leftmargin 更改为 -200,然后当您单击按钮时,我会慢慢将左边距变为 0。所以基本上是一个滑出面板。

问题是如果我让 contentleft 的 leftmargin -200 我不能点击按钮如果我让它 -199 contentleft 的一部分伸出来​​然后按钮只能从左边稍微工作(看起来像 1px)但是不是按钮的其余部分。

我在没有动画的情况下尝试过它,它做的事情和你看到的按钮一样,但如果你点击它,它就不起作用。

这是怎么回事。更糟糕的情况我不介意一些 contentleft 突出,但最好不要显示。

最佳答案

enter image description here

试试这个让你的按钮宽度图像多一点......

右侧的一些部分使其透明。

不会显示,也可以获取点击事件

希望这对你有帮助......!

关于Android形状按钮点击区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10399630/

相关文章:

android - Activity 和/或服务

java - 无法解析方法 setText(java.lang.String)

c# - Unity 3d 动画

javascript - HTML + Canvas : Constellation background animation

javascript - knockout 按钮单击绑定(bind)以更改文本

android - 如何使用Volley库通过套接字(IP地址)和端口号(例如1234)进行网络调用?

python - 我的 matplotlib ArtistAnimation 做错了什么?

javascript - 当按键 "pressed"时,捕获 HTML 按钮上的 mousedown 事件

c# - 如何通过单击事件隐藏或显示图像

android - Espresso 如何等待一段时间(1 小时)?