我有以下形状
<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 突出,但最好不要显示。
最佳答案
试试这个让你的按钮宽度图像多一点......
右侧的一些部分使其透明。
不会显示,也可以获取点击事件
希望这对你有帮助......!
关于Android形状按钮点击区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10399630/