本文整理汇总了Java中android.view.ViewGroup.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.setBackgroundColor方法的具体用法?Java ViewGroup.setBackgroundColor怎么用?Java ViewGroup.setBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.setBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPanel
import android.view.ViewGroup; //导入方法依赖的package包/类
private ViewGroup getPanel(Context context, int type) {
final ViewGroup mViewGroup = new LinearLayout(context);
LinearLayout.LayoutParams btnParam =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// btnParam.weight = 1;
btnParam.gravity = Gravity.CENTER_VERTICAL;
LinearLayout.LayoutParams seekBarParam =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
seekBarParam.weight = 1;
seekBarParam.gravity = Gravity.CENTER;
ImageButton btnBack = new ImageButton(context);
btnBack.setImageBitmap(backBitmap);
btnBack.setScaleType(ImageView.ScaleType.FIT_CENTER);
btnBack.setBackgroundColor(Color.alpha(255));
SeekBar seekBar = getSeekBar(context, type);
ImageButton btnFunc = new ImageButton(context);
btnFunc.setImageBitmap(funcBitmap);
btnFunc.setScaleType(ImageView.ScaleType.FIT_CENTER);
btnFunc.setBackgroundColor(Color.alpha(255));
mViewGroup.addView(btnBack, btnParam);
mViewGroup.addView(seekBar, seekBarParam);
mViewGroup.addView(btnFunc, btnParam);
final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mViewGroup.setBackgroundColor(Color.BLACK);
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
wm.removeView(mViewGroup);
}
});
return mViewGroup;
}
示例2: createRowViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
mR = parent.getResources();
// We create the base class view holder first
ViewHolder fullWidthViewHolder = (ViewHolder)super.createRowViewHolder(parent);
// We expand the info view and put it inside the parent fullwidth container
ViewGroup fullwidthContainer = (ViewGroup)fullWidthViewHolder.getMainContainer();
View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.leanback_details_plot_and_genres_group, fullwidthContainer, false);
fullwidthContainer.addView(detailsView);
fullwidthContainer.setBackgroundColor(mColor);
return new PlotAndGenresViewHolder(fullWidthViewHolder, detailsView);
}
示例3: createRowViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
mR = parent.getResources();
// We create the base class view holder first
ViewHolder fullWidthViewHolder = (ViewHolder)super.createRowViewHolder(parent);
// We expand the info view and put it inside the parent fullwidth container
ViewGroup fullwidthContainer = (ViewGroup)fullWidthViewHolder.getMainContainer();
View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.leanback_details_director_and_cast_group, fullwidthContainer, false);
fullwidthContainer.addView(detailsView);
fullwidthContainer.setBackgroundColor(mColor);
return new CastViewHolder(fullWidthViewHolder, detailsView);
}
示例4: setColorForSwipeBack
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
contentView.setPadding(0, getStatusBarHeight(activity), 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
setTransparentForWindow(activity);
}
}
示例5: setColorForSwipeBack
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例6: animateRevealColorFromCoordinates
import android.view.ViewGroup; //导入方法依赖的package包/类
private Animator animateRevealColorFromCoordinates(ViewGroup viewRoot, @ColorRes int color, int x, int y) {
float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
viewRoot.setBackgroundColor(ContextCompat.getColor(this, color));
anim.setDuration(getResources().getInteger(R.integer.anim_duration_long));
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.start();
return anim;
}
示例7: setColorForSwipeBack
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, int color, int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
contentView.setPadding(0, getStatusBarHeight(activity), 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
setTransparentForWindow(activity);
}
}
示例8: setColorForSwipeBack
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例9: initView
import android.view.ViewGroup; //导入方法依赖的package包/类
private void initView() {
LayoutInflater layoutInflater = getLayoutInflater();
mListContainer = (HorizontalScrollViewEx1) findViewById(R.id.container);
int screenWidth = MyUtil.getScreenMetrics(this).widthPixels;
for (int i = 0; i < 3; i++) {
ViewGroup layout = (ViewGroup) layoutInflater.inflate(R.layout.content_layout1, mListContainer, false);
layout.getLayoutParams().width = screenWidth;
TextView textView = (TextView) layout.findViewById(R.id.title);
textView.setText("page " + (i + 1));
layout.setBackgroundColor(Color.rgb(255 / (i + 1), 255 / (i + 1), 0));
createList(layout);
mListContainer.addView(layout);
}
}
示例10: setColorForSwipeBack
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例11: createNewTabOpenedAnimator
import android.view.ViewGroup; //导入方法依赖的package包/类
private Animator createNewTabOpenedAnimator(
StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
Tab tab = model.getTabAt(focusIndex);
if (tab == null || !tab.isNativePage()) return null;
View view = tab.getView();
if (view == null) return null;
// Set up the view hierarchy
if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
ViewGroup bgView = new FrameLayout(view.getContext());
bgView.setBackgroundColor(tab.getBackgroundColor());
bgView.addView(view);
container.addView(
bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// Update any compositor state that needs to change
if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
tabs[focusIndex].setAlpha(0.f);
}
// Build the view animations
PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
bgView, xScale, yScale, alpha);
animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);
float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;
bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
return animator;
}
示例12: createRowViewHolder
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
// We create the base class view holder first
ViewHolder fullWidthViewHolder = (ViewHolder)super.createRowViewHolder(parent);
// We expand the info view and put it inside the parent fullwidth container
ViewGroup fullwidthContainer = fullWidthViewHolder.getMainContainer();
View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.androidtv_subtitles_info_group, fullwidthContainer, false);
fullwidthContainer.addView(detailsView);
fullwidthContainer.setBackgroundColor(mColor);
return new SubtitlesDetailsViewHolder(fullWidthViewHolder, detailsView);
}
示例13: setColorForSwipeBack
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
示例14: updateListBG
import android.view.ViewGroup; //导入方法依赖的package包/类
private void updateListBG(ViewGroup vg){
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int mainColor = themePrefs.getInt("contactsRowColor", 0xffffffff);
int value = themePrefs.getInt("contactsRowGradient", 0);
boolean b = true;//themePrefs.getBoolean("contactsRowGradientListCheck", false);
if(value > 0 && b) {
GradientDrawable.Orientation go;
switch(value) {
case 2:
go = GradientDrawable.Orientation.LEFT_RIGHT;
break;
case 3:
go = GradientDrawable.Orientation.TL_BR;
break;
case 4:
go = GradientDrawable.Orientation.BL_TR;
break;
default:
go = GradientDrawable.Orientation.TOP_BOTTOM;
}
int gradColor = themePrefs.getInt("contactsRowGradientColor", 0xffffffff);
int[] colors = new int[]{mainColor, gradColor};
GradientDrawable gd = new GradientDrawable(go, colors);
vg.setBackgroundDrawable(gd);
}else{
vg.setBackgroundColor(mainColor);
}
}
示例15: updateListBG
import android.view.ViewGroup; //导入方法依赖的package包/类
private void updateListBG(ViewGroup vg) {
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int mainColor = themePrefs.getInt("contactsRowColor", 0xffffffff);
int value = themePrefs.getInt("contactsRowGradient", 0);
boolean b = true;//themePrefs.getBoolean("contactsRowGradientListCheck", false);
if (value > 0 && b) {
GradientDrawable.Orientation go;
switch (value) {
case 2:
go = GradientDrawable.Orientation.LEFT_RIGHT;
break;
case 3:
go = GradientDrawable.Orientation.TL_BR;
break;
case 4:
go = GradientDrawable.Orientation.BL_TR;
break;
default:
go = GradientDrawable.Orientation.TOP_BOTTOM;
}
int gradColor = themePrefs.getInt("contactsRowGradientColor", 0xffffffff);
int[] colors = new int[]{mainColor, gradColor};
GradientDrawable gd = new GradientDrawable(go, colors);
vg.setBackgroundDrawable(gd);
} else {
vg.setBackgroundColor(mainColor);
}
}