TransitionDrawable 不考虑填充?
我尝试了此处发布的已接受解决方案,但似乎忽略填充。当第二个视图(在本例中是一个按钮)显示时,它比带有填充的原始视图小得多。有解决方法吗?谢谢
I tried the accepted solution posted here, but it appears to ignore padding. When the second view (in this case a button) displays, it's much smaller than the original which has padding. Is there a workaround for that? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,
TransitionDrawable
继承自LayerDrawable
,它忽略了填充。这是基本 Android 代码中的getPadding()
方法,它会删除您指定的任何内容:请参阅 此处为基本 Android 代码。
为了解决这个问题,我必须先保存填充值,然后再在视图上设置错误的可绘制背景:
Yes,
TransitionDrawable
extends fromLayerDrawable
which ignores the padding. This is thegetPadding()
method in the base Android code, which gets rid of anything you specified:See base Android code here.
To deal with it, I had to first save the padding values before setting the faulty drawable background on my view: