创建后如何更改InsetDrawable Inset值 [英] How to Change InsetDrawable Inset value after creation

查看:64
本文介绍了创建后如何更改InsetDrawable Inset值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了InsetDrawable,我希望能够在运行时调整inset的值,而无需重新分配另一个drawable.

I have an InsetDrawable defined, and I would just like to be able to adjust the value of the inset at runtime, without re-assigning another drawable.

这可能吗?还是唯一的方法是重新创建InsetDrawable?

Is this possible?, or is the only way is to re-create the InsetDrawable?

推荐答案

这是不可能的,因为该API并不公开. 我遇到了与您相同的问题,但就我而言,我必须对插图进行动画处理,因此重新创建可绘制对象是一个非常昂贵的选择.

It is not possible, because the API for that is not public. I had the same problem as you did, but in my case I had to animate the insets, so recreating the drawable was a quite costly option.

最后,我复制了InsetDrawable的源代码,并添加了一种更改inset的方法.

In the end I copied the source code of InsetDrawable, and added a method for changing the inset.

您可以在此处进行查看.使用方法setInsets()更改插图.

You can check it out here. Use the method setInsets() for changing the insets.

这篇关于创建后如何更改InsetDrawable Inset值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆