如何将按钮文本时的状态是pressed如何将、按钮、文本、状态

2023-09-06 13:31:38 作者:在看你的背后

我做了一个自定义背景的按钮,也为不同的按钮状态。但现在我要,我无法理解一个点进行。

I made a custom background for a button and also for different button states. But now I made to a point that I cannot understand.

当按钮处于正常状态,那么它看起来就好了。但是,当我preSS的按钮,我需要将文本向下几个像素,因为按钮的背景图像中移动(实际上这感觉就像是运动的形象,因为首先有边框的按钮下,当它在pressed状态那么这个边界消失)。请参见下图。

When button is in normal state then it looks just fine. But when I press the button, I need to move text down few pixels because button background image moving (actually it feels like it moving on the image, because first there's border under the button and when it's in pressed state then this border disappears). Please see image below.

我如何可以移动的按钮,按钮的文字时,按钮状态pressed? (也许在某种程度上填补或布局定制的按钮)

How can I move the buttons text in the button when buttons state is pressed? (maybe padding somehow or layout custom for a button)

推荐答案

我没有尝试自己,但如果你用九个补丁作为背景绘制这两个州,那么你应该考虑在pressed设置适当的填充盒国家绘制。查看详情这里 。

I did not try it myself but if you use nine-patch as a background drawable for both states then you should consider setting proper padding box in pressed state drawable. See details here.