本文整理匯總了Java中android.content.Context.getColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.getColor方法的具體用法?Java Context.getColor怎麽用?Java Context.getColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.Context
的用法示例。
在下文中一共展示了Context.getColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateStatus
import android.content.Context; //導入方法依賴的package包/類
private void updateStatus(FFMStatus status) {
if (status.getGroupBlacklist() != null) {
FFMSettings.putLocalGroupWhitelistValue(status.getGroupBlacklist().isEnabled() ? status.getGroupBlacklist().getCount() : -1);
}
if (status.getDiscussWhitelist() != null) {
FFMSettings.putLocalDiscussWhitelistValue(status.getDiscussWhitelist().isEnabled() ? status.getDiscussWhitelist().getCount() : -1);
}
if (status.isRunning()) {
updateStatus(status.getDevices());
} else {
Context context = getContext();
int color = context.getColor(R.color.serverProblem);
Drawable icon = context.getDrawable(R.drawable.ic_status_error_24dp);
updateStatus(context.getString(R.string.status_webqq_dead), color, icon);
}
}
示例2: getColor
import android.content.Context; //導入方法依賴的package包/類
public int getColor(int resId, Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
//noinspection deprecation
return context.getResources().getColor(resId);
} else {
return context.getColor(resId);
}
}
示例3: fixTitlebarColor
import android.content.Context; //導入方法依賴的package包/類
private void fixTitlebarColor(Toolbar toolbar, Context context) {
int textColor = 0;
if(SDK_INT <= 23) {
textColor = Color.parseColor("#ffffffff");
} else {
textColor = context.getColor(R.color.editTitlebarTextColor);
}
toolbar.setTitleTextColor(textColor);
TextView saveItem = (TextView) toolbar.findViewById(R.id.save_menu);
saveItem.setTextColor(textColor);
}
示例4: AlbumPictureController
import android.content.Context; //導入方法依賴的package包/類
public AlbumPictureController(Context context, final ImageSwitcher view, int size) {
this.view = view;
this.size = size;
this.context = context;
this.cache = new BitmapCache(context, BitmapCache.CACHE_ALBUM_VISUALIZER_IMAGE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
defaultColor = context.getColor(R.color.default_play_bg_color);
defaultTextColor = context.getColor(R.color.default_play_text_color);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
defaultColor = context.getResources().getColor(R.color.default_play_bg_color, null);
defaultTextColor = context.getResources().getColor(R.color.default_play_text_color, null);
} else {
defaultColor = context.getResources().getColor(R.color.default_play_bg_color);
defaultTextColor = context.getResources().getColor(R.color.default_play_text_color);
}
this.bitmapProducer = new BitmapProducer(context);
colors = new int[]{
defaultColor,
defaultTextColor,
defaultColor,
defaultTextColor
};
rotateAnim = ObjectAnimator.ofFloat(0, 360);
rotateAnim.setDuration(45 * 1000);
rotateAnim.setRepeatMode(ValueAnimator.RESTART);
rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
rotateAnim.setInterpolator(new LinearInterpolator());
rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
view.getCurrentView().setRotation(value);
}
});
}
示例5: get10WhiteThemeColors
import android.content.Context; //導入方法依賴的package包/類
/**
* 0 狀態欄背景色<br>
* 1 標題欄背景色<br>
* 2 控件首選色<br>
* 3 主背景色<br>
* 4 輔背景色<br>
* 5 主字體色<br>
* 6 輔字體色<br>
* 7 底部導航背景色<br>
* 8 標題欄主字體色<br>
* 9 標題欄輔字體色<br>
*/
public static int[] get10WhiteThemeColors(Context context) {
int[] colors = new int[10];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_white_primary);
colors[1] = context.getColor(R.color.theme_white_primary_dark);
colors[2] = context.getColor(R.color.theme_white_accent);
colors[3] = context.getColor(R.color.theme_white_main_bg);
colors[4] = context.getColor(R.color.theme_white_vic_bg);
colors[5] = context.getColor(R.color.theme_white_main_text);
colors[6] = context.getColor(R.color.theme_white_vic_text);
colors[7] = context.getColor(R.color.theme_white_nav);
colors[8] = context.getColor(R.color.theme_white_toolbar_main_text);
colors[9] = context.getColor(R.color.theme_white_toolbar_vic_text);
} else {
colors[0] = context.getResources().getColor(R.color.theme_white_primary);
colors[1] = context.getResources().getColor(R.color.theme_white_primary_dark);
colors[2] = context.getResources().getColor(R.color.theme_white_accent);
colors[3] = context.getResources().getColor(R.color.theme_white_main_bg);
colors[4] = context.getResources().getColor(R.color.theme_white_vic_bg);
colors[5] = context.getResources().getColor(R.color.theme_white_main_text);
colors[6] = context.getResources().getColor(R.color.theme_white_vic_text);
colors[7] = context.getResources().getColor(R.color.theme_white_nav);
colors[8] = context.getResources().getColor(R.color.theme_white_toolbar_main_text);
colors[9] = context.getResources().getColor(R.color.theme_white_toolbar_vic_text);
}
AppPreference preference = new AppPreference(context);
colors[2] = preference.getAccentColor();
return colors;
}
示例6: get10DarkThemeColors
import android.content.Context; //導入方法依賴的package包/類
/**
* 0 狀態欄背景色<br>
* 1 標題欄背景色<br>
* 2 控件首選色<br>
* 3 主背景色<br>
* 4 輔背景色<br>
* 5 主字體色<br>
* 6 輔字體色<br>
* 7 底部導航背景色<br>
* 8 標題欄主字體色<br>
* 9 標題欄輔字體色<br>
*/
public static int[] get10DarkThemeColors(Context context) {
int[] colors = new int[10];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_dark_primary);
colors[1] = context.getColor(R.color.theme_dark_primary_dark);
colors[2] = context.getColor(R.color.theme_dark_accent);
colors[3] = context.getColor(R.color.theme_dark_main_bg);
colors[4] = context.getColor(R.color.theme_dark_vic_bg);
colors[5] = context.getColor(R.color.theme_dark_main_text);
colors[6] = context.getColor(R.color.theme_dark_vic_text);
colors[7] = context.getColor(R.color.theme_dark_nav);
colors[8] = context.getColor(R.color.theme_dark_toolbar_main_text);
colors[9] = context.getColor(R.color.theme_dark_toolbar_vic_text);
} else {
colors[0] = context.getResources().getColor(R.color.theme_dark_primary);
colors[1] = context.getResources().getColor(R.color.theme_dark_primary_dark);
colors[2] = context.getResources().getColor(R.color.theme_dark_accent);
colors[3] = context.getResources().getColor(R.color.theme_dark_main_bg);
colors[4] = context.getResources().getColor(R.color.theme_dark_vic_bg);
colors[5] = context.getResources().getColor(R.color.theme_dark_main_text);
colors[6] = context.getResources().getColor(R.color.theme_dark_vic_text);
colors[7] = context.getResources().getColor(R.color.theme_dark_nav);
colors[8] = context.getResources().getColor(R.color.theme_dark_toolbar_main_text);
colors[9] = context.getResources().getColor(R.color.theme_dark_toolbar_vic_text);
}
return colors;
}
示例7: get2WhiteThemeTextColor
import android.content.Context; //導入方法依賴的package包/類
/**
* 0 主字體顏色
* 1 輔字體顏色
*/
public static int[] get2WhiteThemeTextColor(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_white_main_text); //主字體色
colors[1] = context.getColor(R.color.theme_white_vic_text); // 輔字體色
} else {
colors[0] = context.getResources().getColor(R.color.theme_white_main_text);
colors[1] = context.getResources().getColor(R.color.theme_white_vic_text);
}
return colors;
}
示例8: get2DarkThemeTextColor
import android.content.Context; //導入方法依賴的package包/類
/**
* 0 主字體顏色
* 1 輔字體顏色
*/
public static int[] get2DarkThemeTextColor(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_dark_main_text); //主字體色
colors[1] = context.getColor(R.color.theme_dark_vic_text); // 輔字體色
} else {
colors[0] = context.getResources().getColor(R.color.theme_dark_main_text);
colors[1] = context.getResources().getColor(R.color.theme_dark_vic_text);
}
return colors;
}
示例9: get2ToolbarTextColors
import android.content.Context; //導入方法依賴的package包/類
public static int[] get2ToolbarTextColors(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.white_d);
colors[1] = context.getColor(R.color.white_d_d);
} else {
colors[0] = context.getResources().getColor(R.color.white_d);
colors[1] = context.getResources().getColor(R.color.white_d_d);
}
return colors;
}
示例10: get2ColorWhiteThemeForPlayOptions
import android.content.Context; //導入方法依賴的package包/類
public static int[] get2ColorWhiteThemeForPlayOptions(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.dark_l_l_l_l);
colors[1] = context.getColor(R.color.white_d_d_d);
} else {
colors[0] = context.getResources().getColor(R.color.dark_l_l_l_l);
colors[1] = context.getResources().getColor(R.color.white_d_d_d);
}
return colors;
}
示例11: get2ColorDarkThemeForPlayOptions
import android.content.Context; //導入方法依賴的package包/類
public static int[] get2ColorDarkThemeForPlayOptions(Context context) {
int[] colors = new int[2];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.white_d_d);
colors[1] = context.getColor(R.color.white_d_d_d);
} else {
colors[0] = context.getResources().getColor(R.color.white_d_d);
colors[1] = context.getResources().getColor(R.color.white_d_d_d);
}
return colors;
}
示例12: getColor
import android.content.Context; //導入方法依賴的package包/類
public static int getColor(Context context, int id){
if (android.os.Build.VERSION.SDK_INT >= 23) {
return context.getColor(id);
} else {
return context.getResources().getColor(id);
}
}
示例13: getColorWrapper
import android.content.Context; //導入方法依賴的package包/類
public static int getColorWrapper(Context context, int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return context.getColor(color);
} else {
//noinspection deprecation
return context.getResources().getColor(color);
}
}
示例14: getColor
import android.content.Context; //導入方法依賴的package包/類
public static int getColor(Context context, int id) {
if (Build.VERSION.SDK_INT >= 23) {
return context.getColor(id);
}
else {
return context.getColor(id);
}
}
示例15: getColor
import android.content.Context; //導入方法依賴的package包/類
private int getColor(Context context, int colorId) {
int paintColor;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
paintColor = context.getColor(colorId);
} else {
paintColor = context.getResources().getColor(colorId);
}
return paintColor;
}