用于Animate TopMargin的ObjectAnimator代理无法找到设置/获取

 手机用户2502923495 发布于 2023-02-13 18:47

我们正在尝试使用objectanimator代理来为Android(Xamarin)中的TopMargin属性设置动画.

但是,我们收到此错误:

[PropertyValuesHolder]找不到属性TopMargin的setter/getter,其值类型为float

注意:我们尝试过TopMargin,topMargin,GetTopMargin,getTopMargin等,认为它可能是Java和C#之间的套管转换问题,但看起来并非如此.

我们在Activity中开始动画的代码:

translation = new int[] {0, 300};
var anim2 = ObjectAnimator.OfInt( new MarginProxyAnimator(myview), "TopMargin",translation);
anim2.SetDuration(500);
anim2.Start(); 

我们的代理类:

public class MarginProxyAnimator : Java.Lang.Object 
{
///... other code...
    public int getTopMargin() {
    var lp = (ViewGroup.MarginLayoutParams)mView.LayoutParameters;
    return lp.TopMargin;
    }

    public void setTopMargin(int margin) {
    var lp = (ViewGroup.MarginLayoutParams)mView.LayoutParameters;
        lp.SetMargins(lp.LeftMargin, margin, lp.RightMargin, lp.BottomMargin);
    mView.RequestLayout();
    }
}

有什么建议吗?使用代理指向工作Xamarin样本的指针会很有帮助.

谢谢.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有