Android的 - 监听器捕获在视图中的属性变化(例如机器人:layout_marginTop) [英] Android - Listener for catching changes in a View's properties (e.g. android:layout_marginTop)
本文介绍了Android的 - 监听器捕获在视图中的属性变化(例如机器人:layout_marginTop)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Android中,你可以创建一个监听器捕获在视图中的属性(相对于屏幕上方宽/高/保证金/位置)的变化?
In Android, can you create a Listener for catching changes in a View's properties (width / height / margin / position relative to top of the screen)?
我要触发一个事件时layout_marginTop =10dp更改为一个不同的值。
I want to trigger an event when layout_marginTop="10dp" is changed to a different value.
推荐答案
有关实现时,一种观点是由于移动到布局更改时调用OnLayoutChangeListener什么
What about implementing a OnLayoutChangeListener that gets called when a View is moved due to Layout Change
new View().addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
int oldTop, int oldRight, int oldBottom) {
// TODO Auto-generated method stub
}
});
这是Android的API摘录:
Excerpt from Android API:
添加
监听器将被调用时视图的变化,由于边界
布局处理。
Add a listener that will be called when the bounds of the view change due to layout processing.
这篇关于Android的 - 监听器捕获在视图中的属性变化(例如机器人:layout_marginTop)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文