动态修改dialog主题使之具有holo样式
来源:互联网 发布:it服务与外包 编辑:程序博客网 时间:2024/06/05 16:43
如果没有定义主题样式可以,动态设定dialog的主题
方法一:
AlertDialog.Builder builder = new AlertDialog.Builder(context,AlertDialog.THEME_HOLO_LIGHT);
////hack for no holo theme related ----begin
int divierId = dialog.getContext().getResources()
.getIdentifier("android:id/titleDivider", null, null);
int titleId = dialog.getContext().getResources()
.getIdentifier("android:id/alertTitle", null, null);
int panelId = dialog.getContext().getResources()
.getIdentifier("android:id/parentPanel", null, null);
int topPanelId = dialog.getContext().getResources()
.getIdentifier("android:id/topPanel", null, null);
dialog.show();
View decorView = (View) dialog.getWindow().getDecorView();
View contentView = decorView.findViewById(android.R.id.content);
if (contentView != null) {
contentView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(TAG, "touch outside");
dialog.dismiss();
return false;
}
});
}
View topPanel = dialog.findViewById(topPanelId);
if (topPanel != null) {
topPanel.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(TAG, "touch topPanel");
return true;
}
});
}
View dividerView = dialog.findViewById(divierId);
if (dividerView != null)
dividerView.setBackgroundColor(dialog.getContext().getResources()
.getColor(R.color.holo_blue_light));
TextView alertTitle = (TextView) dialog.findViewById(titleId);
if (alertTitle != null) {
alertTitle.setTextColor(dialog.getContext().getResources()
.getColor(R.color.holo_blue_light));
alertTitle.setTextSize(DimenUtil.sp2px(10));
}
View parentPanel = dialog.findViewById(panelId);
if (parentPanel != null) {
FrameLayout.LayoutParams lp = (android.widget.FrameLayout.LayoutParams) parentPanel
.getLayoutParams();
if (lp != null) {
lp.gravity = Gravity.CENTER;
parentPanel.setLayoutParams(lp);
}
}
ListView list = dialog.getListView();
if (list != null) {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
dialog.getContext(), R.layout.dialog_list_item,
R.id.textView1, items);
list.setAdapter(adapter);
}
////hack for no holo theme related ----begin
- 动态修改dialog主题使之具有holo样式
- android之4.0的系统主题style修改android:Theme.Holo.Light
- android之4.0的系统主题style修改android:Theme.Holo.Light
- 去掉Holo主题下Dialog的蓝色线
- Octopress主题样式修改
- 修改样式和主题
- 修改主题和样式
- 样式和主题之样式
- 动态修改主题
- EasyUI中的dialog修改样式
- Android动态设置主题样式
- sencha touch 扩展篇之使用sass自定义主题样式 (上)使用官方的api修改主题样式
- sencha touch 扩展篇之使用sass自定义主题样式 (上)使用官方的api修改主题样式
- Angular4 动态修改样式
- android修改HOLO对话框风格
- android修改HOLO对话框风格
- android 之样式和主题
- Android之样式和主题
- C++ Vectors
- JAXB
- python webdriver测试报告
- 2.29
- 我的第一个JAVA程序
- 动态修改dialog主题使之具有holo样式
- eMMC分区详解
- tar 命令详细使用介绍
- 愚人节,不恶搞,我们玩真的。不服来战!
- 如何使用CMenu类创建菜单
- URL中文乱码
- java实现斐波那契数列和约瑟夫环
- Eclipse不编译java代码
- BZOJ 1141 POI2009 Slw