1. 重新写一个RadioGroup,可以实现嵌套布局的,请见http://www.cnblogs.com/Jaylong/p/3641027.html,可自行在该网页中复制代码FlowRadioGroup运用到项目中,将FlowRadioGroup代替原来xml中的RadioGroup。
2. 从git上获取一份viewbadger的源码,然后修改BadgeView.java中的applyTo函数,代码如下(可直接复制拷贝进去覆盖原函数):
然后将其引入我们自己的项目中,这样就可以完美实现我们想要的功能了, ~
2. 从git上获取一份viewbadger的源码,然后修改BadgeView.java中的applyTo函数,代码如下(可直接复制拷贝进去覆盖原函数):
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
|
private
void
applyTo(View target) {
LayoutParams lp = target.getLayoutParams();
ViewParent parent = target.getParent();
FrameLayout container =
new
FrameLayout(context);
if
(target
instanceof
TabWidget) {
// set target to the relevant tab child container
target = ((TabWidget) target).getChildTabViewAt(targetTabIndex);
this
.target = target;
((ViewGroup) target).addView(container,
new
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
this
.setVisibility(View.GONE);
container.addView(
this
);
}
else
{
// TODO verify that parent is indeed a ViewGroup
ViewGroup group = (ViewGroup) parent;
int
index = group.indexOfChild(target);
group.removeView(target);
// 2015.11.02 Modified by zhangrong_lu
// 把container.addView置于group.addView之前
// container.addView的参数要用LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
container.addView(target,
new
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
group.addView(container, index, lp);
this
.setVisibility(View.GONE);
container.addView(
this
);
group.invalidate();
}
}
|
然后将其引入我们自己的项目中,这样就可以完美实现我们想要的功能了, ~