有关自定义应用程序用户界面和AlphaAnimation的两个问题 [英] Two questions about custom app ui's and AlphaAnimation

查看:30
本文介绍了有关自定义应用程序用户界面和AlphaAnimation的两个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我真的从中获得了大量有关自定义和动画的知识.现在,我正在使用自定义UI元素对我的应用程序进行外观设置,但是我不确定自己是否正确执行了此操作.

So I'm really picking up a lot of knowledge about customizations and animations. Right now I'm skinning my app with custom UI elements, but I'm not sure if I'm doing this correctly.

几乎我正在使用不同的按钮状态等在我的drawable文件夹中创建一个xml文件.然后在我的样式xml中,创建一个引用复选框xml的自定义(例如)复选框样式.然后,在我的布局xml中,创建一个普通的复选框,并调用我制作的复选框样式.效果很好,但是我不确定这是否是一种有效的方法?

Pretty much I'm creating a an xml file in my drawable folder with different button states and so forth. Then in my styles xml, I create a custom (for example) check box style referencing the check box xml. Then in my layout xml I create a normal checkbox and call the check box style I made. Works great, but I'm not sure if this is an efficient approach?

2,我正在学习动画,我觉得用Java编写动画比使用XML编程容易,这使我进入了AlphaAnimation().Alpha动画需要两个长变量.当我执行AlphaAnimation(1,0)时,它可以很好地淡出,但是我希望它可以淡出50%,而从我在XML版本中所学到的知识中,我可以做到50%时可以做到0.5.因此,我将键入AlphaAnimation(1,05),但显然这是行不通的.我该怎么做?

2nd, I'm learning animations and I feel that programming the animations in Java is easier then XML, which brings me to AlphaAnimation(). Alpha animation requires two long variables. When I do AlphaAnimation(1,0), it fades out fine, but I wanted to have it fade out 50% and from what I've learned in the XML version, I can do 0.5 as 50%. So I would type AlphaAnimation(1,05), but obviously that doesn't work. HOw do I go about doing that?

谢谢!

推荐答案

1)听起来很合理,而且几乎是标准方法.

1) Sound quite reasonable and pretty much the standard way to do it.

2)您非常亲密:

AlphaAnimation alpha = new AlphaAnimation (1f, 0.5f); // from 100% visible to 50%
alpha.setDuration (1000); // 1 second, or whatever you want

// all your code here

myView.startAnimation(alpha); // execute it after a click or the event you want

这篇关于有关自定义应用程序用户界面和AlphaAnimation的两个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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