如何设置" toYDelta"在java中code属性? [英] How to set "toYDelta" attribute in java code?
问题描述
我有许多的TextView
和下面的每个人,一个 tableLayout
有 visibility.GONE
在开始的时候。
我试图展开 tableLayout
这是属于的TextView
在的TextView
点击。我已经指派字母
动画 tableLayout
和翻译
动画的的TextView
是被点击以下任一。
I've got many textView
s and below each of them, a tableLayout
which has visibility.GONE
at the very beginning .
I am trying to expand the tableLayout
which is belong to a textView
when the textView
is clicked . I've assigned alpha
animation to tableLayout
s and translate
animation to those textView
s are below the clicked one .
由于大小我的 tableLayout
是不同的我必须设置 toYDelta code>和
fromYDelta
分别为每点击的TextView
一个新的动画!
我认为这完全是很难code!
since the size of my tableLayout
are different I have to set toYDelta
and fromYDelta
separately in a new animation for clicking every textView
!!
and I think it is totally hard code !!!
我的问题是:有没有我可以用它来修改任何方法 toYDelta code> 5月code编程
My question is : Is there any method I can use it to modify toYDelta
in may code programmatically ?
或任何人可以帮助我其他的方式来做到这一点吗?
Or can anyone help me other way to do that please ?
推荐答案
有这样做的几种选择。最简单的可能就是使用 ViewPropertyAnimator
,例如
There are several alternatives for doing this. The simplest one is probably to use a ViewPropertyAnimator
, e.g.
view.animate().translationY(value);
要获取的当前值(例如,如果你想用一个固定偏移更新它),你可以使用的 view.getTranslationY()
。
To get the current value (for example if you want to update it with a fixed offset) you can use view.getTranslationY()
.
请参阅 http://developer.android.com/guide/topics /graphics/prop-animation.html
这篇关于如何设置" toYDelta"在java中code属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!