如何在android内部搜索控件下的子控件
2015-02-08
展开全部
* 遍历所有view
*
* @param viewGroup
*/
public void traversalView(ViewGroup viewGroup) {
int count = viewGroup.getChildCount();
for (int i = 0; i < count; i++) {
View view = viewGroup.getChildAt(i);
if (view instanceof ViewGroup) {
traversalView((ViewGroup) view);
} else {
doView(view);
}
}
}
/**
* 处理view
*
* @param view
*/
private void doView(View view) {
}
*
* @param viewGroup
*/
public void traversalView(ViewGroup viewGroup) {
int count = viewGroup.getChildCount();
for (int i = 0; i < count; i++) {
View view = viewGroup.getChildAt(i);
if (view instanceof ViewGroup) {
traversalView((ViewGroup) view);
} else {
doView(view);
}
}
}
/**
* 处理view
*
* @param view
*/
private void doView(View view) {
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2016-01-21 · 知道合伙人影视综艺行家
关注
展开全部
先通过getChildAt(int index)获取到子控件,再通过lp = getLayoutParams()获取到子控件的参数,lp.leftMargin就是你想要的数值
View child = getChildAt(0);
MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
int leftMargin = lp.leftMargin
View child = getChildAt(0);
MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
int leftMargin = lp.leftMargin
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |