asysbang
标题:
修改标题栏
[打印本页]
作者:
admin
时间:
2013-5-13 10:04
标题:
修改标题栏
开发应用有时需要对标题栏做些修改,当然可以隐藏默认的标题栏,然后自己实现一个标题栏
这里举例只是介绍一种方法,提供一种思路
利用ViewGroup遍历子view来处理一些问题
自己用过的一个自动化测试框架就利用了这种方式,虽然效率不高,但有时可以解决一些不能解决的问题,同时可以利用系统编译生成的R.java文件
public class TitleActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewGroup rootView = (ViewGroup) getWindow().getDecorView();
int childCount = rootView.getChildCount();
System.out.println("==============="+childCount);
ViewGroup l1 = (ViewGroup) rootView.getChildAt(0);
int i = l1.getChildCount();
System.out.println("==============="+i);
View v = l1.getChildAt(0);
String str = v.getClass().getSimpleName();
System.out.println("============"+str);
if ("ActionBarContainer".equals(str)){
System.out.println("========equal=====");
v.setBackgroundColor(Color.RED);
}
}
}
欢迎光临 asysbang (http://www.asysbang.com/)
Powered by Discuz! X2.5