當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.setBackgroundColor方法代碼示例

本文整理匯總了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;
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:39,代碼來源:LightAndVolumeController.java

示例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);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:PlotAndGenresRowPresenter.java

示例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);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:CastRowPresenter.java

示例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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:StatusBarUtil.java

示例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);
    }
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:40,代碼來源:BarUtils.java

示例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;
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:11,代碼來源:RevealActivity.java

示例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);
    }
}
 
開發者ID:tututututututu,項目名稱:BaseCore,代碼行數:16,代碼來源:BarUtils.java

示例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);
    }
}
 
開發者ID:GuoZhaoHui628,項目名稱:SliderStatusBar,代碼行數:39,代碼來源:StatusBarUtil.java

示例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);
    }
}
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:15,代碼來源:Demo1Activity.java

示例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);
    }
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:39,代碼來源:UIStatusBarController.java

示例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;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:38,代碼來源:StackViewAnimation.java

示例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);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:14,代碼來源:SubtitlesDetailsRowPresenter.java

示例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);
    }
}
 
開發者ID:wheat7,項目名稱:VRPlayer,代碼行數:40,代碼來源:StatusBarUtil.java

示例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);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:30,代碼來源:OnlineContactsAdapter.java

示例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);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:30,代碼來源:ContactsAdapter.java


注:本文中的android.view.ViewGroup.setBackgroundColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。