Android的:如何获得活动的背景颜色在Java中? [英] Android: How to get background color of Activity in Java?

查看:92
本文介绍了Android的:如何获得活动的背景颜色在Java中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到背景颜色和文字颜色(默认为子视图)的活动中的Java?

解决方案

  TypedArray阵列= getTheme()。obtainStyledAttributes(新INT [] {
    android.R.attr.colorBackground,
    android.R.attr.textColorPrimary,
});
INT的backgroundColor = array.getColor(0,0xFF00FF);
INT文字颜色= array.getColor(1,0xFF00FF);
array.recycle();
 

How can I get background color and text color (default for child views) of an Activity in Java?

解决方案

TypedArray array = getTheme().obtainStyledAttributes(new int[] {  
    android.R.attr.colorBackground, 
    android.R.attr.textColorPrimary, 
}); 
int backgroundColor = array.getColor(0, 0xFF00FF); 
int textColor = array.getColor(1, 0xFF00FF); 
array.recycle();

这篇关于Android的:如何获得活动的背景颜色在Java中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆