-
Notifications
You must be signed in to change notification settings - Fork 14
/
ViewWrapper.java
46 lines (38 loc) · 929 Bytes
/
ViewWrapper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import android.view.View;
/**
* ViewWrapper
*
* 装饰 view,给 view 赋予setWidth、getWidth、setHeight、getHeight等方法,
* 供属性动画中使用改变 view 的 width、height
*
* @author: onlylemi
*/
public class ViewWrapper {
private View view;
private ViewWrapper(View view) {
this.view = view;
}
/**
* 装饰 view
*
* @param view
* @return
*/
public static ViewWrapper decorator(View view) {
return new ViewWrapper(view);
}
public int getHeight() {
return view.getLayoutParams().height;
}
public void setHeight(int height) {
view.getLayoutParams().height = height;
view.requestLayout();
}
public int getWidth() {
return view.getLayoutParams().width;
}
public void setWidth(int width) {
view.getLayoutParams().width = width;
view.requestLayout();
}
}