Example usage for android.view ViewGroup setBackgroundColor

List of usage examples for android.view ViewGroup setBackgroundColor

Introduction

In this page you can find the example usage for android.view ViewGroup setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:de.da_sense.moses.client.AvailableFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d("AvailableFragment", "onCreateView about to inflate View");
    View availbleFragmentView = inflater.inflate(R.layout.tab_available, container, false);
    container.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    return availbleFragmentView;
}

From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java

public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) {
    super(fm);//  w  ww .j a  v  a2s .  co m
    this.mActivity = activity;
    mPager = ((ViewPager) mActivity.findViewById(R.id.pager));
    mPager.setOnTouchListener(exitTouchListener);
    if (Build.VERSION.SDK_INT >= 17)
        rightToLeft = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == 1;
    if (rightToLeft) {
        List<Integer> list = Arrays.asList(colors);
        Collections.reverse(list);
        colors = (Integer[]) list.toArray();
    }
    ImageButton pagerArrow = ((ImageButton) mActivity.findViewById(R.id.pager_arrow));
    Button okButton = ((Button) mActivity.findViewById(R.id.pager_ok));
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Tutorial_5.nlEnabled) {
                final ViewGroup nlFrame = (ViewGroup) activity.findViewById(R.id.NL_frame);
                final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        Color.parseColor("#30000000"), Color.parseColor("#80FFFFFF"));
                colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        nlFrame.setBackgroundColor((int) animation.getAnimatedValue());
                    }
                });
                colorAnimation.setInterpolator(new LinearOutSlowInInterpolator());
                colorAnimation.setRepeatCount(3);
                colorAnimation.setRepeatMode(ValueAnimator.REVERSE);
                colorAnimation.setDuration(650L);
                colorAnimation.start();
            } else if (!hasClicked) {
                exitAction();
                hasClicked = true;
            }
        }
    });
    pagerArrow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nextAction();
        }
    });
}

From source file:de.da_sense.moses.client.FormFragment.java

/**
 * Creates a Layout for a Single_Questionnaire
 * /*from  w  w  w .  ja  v  a2  s. c  o m*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Intent intent = getActivity().getIntent();
    mBelongsTo = intent.getIntExtra(WelcomeActivity.KEY_BELONGS_TO, WelcomeActivityPagerAdapter.TAB_RUNNING);

    mLayoutInflater = inflater;

    container.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    if (savedInstanceState != null) {
        if (mPosition == -1)
            mPosition = savedInstanceState.getInt(KEY_POSITION, -1);

        if (mAPKID == null)
            mAPKID = savedInstanceState.getString(InstalledExternalApplication.KEY_APK_ID, null);
    }

    if (mAPKID == null)
        Log.e(LOG_TAG, "onCreateView the APKID was not set and not in the bundle");

    // check the presence of the formID
    if (mFormID == -1) {
        // the id is not set, it must be in the bundle
        mFormID = savedInstanceState.getInt(Form.KEY_FORM_ID, -1);
        if (mFormID == -1)
            // the id of the form was not in the bundle, this should never have happened
            Log.e(LOG_TAG, "onCreateView the formID was not set and not in the bundle");
    }

    ExternalApplication app;

    // get the corresponding installedApp
    if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY) {
        app = HistoryExternalApplicationsManager.getInstance().getAppForId(mAPKID);
    } else {
        app = InstalledExternalApplicationsManager.getInstance().getAppForId(mAPKID);
    }

    if (app != null) {
        mForm = app.getSurvey().getForm(mFormID);
    }

    mRoot = (LinearLayout) inflater.inflate(R.layout.form, container, false);

    mScrollView = (ScrollView) mRoot.findViewById(R.id.scrollView1);

    // set focus to the dummy layout in order to prevent virtual keyboard from popping up
    View dummyLayout = mRoot.findViewById(R.id.dummy_layout_form);
    dummyLayout.requestFocus();

    addFormToLayout(mForm, mRoot);

    if (savedInstanceState != null) {
        if (mIsFirst == null)
            mIsFirst = savedInstanceState.getBoolean(KEY_IS_FIRST);

        if (mIsLast == null)
            mIsLast = savedInstanceState.getBoolean(KEY_IS_LAST);
    }

    return (View) mRoot;
}

From source file:com.aniruddhc.acemusic.player.FoldersFragment.FilesFoldersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_folders, container, false);
    mContext = getActivity().getApplicationContext();
    mFilesFoldersFragment = this;
    mApp = (Common) mContext;//from w w  w  .j av a2 s .c  om
    mFolderStateMap = new HashMap<String, Parcelable>();

    //Set the hidden files flag.
    SHOW_HIDDEN_FILES = mApp.getSharedPreferences().getBoolean("SHOW_HIDDEN_FILES", false);

    listView = (ListView) rootView.findViewById(R.id.folders_list_view);
    listView.setFastScrollEnabled(true);
    listView.setVisibility(View.INVISIBLE);

    //Set the background color based on the theme.
    rootView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    //Apply the ListView params.
    //Apply the ListViews' dividers.
    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        listView.setDivider(mContext.getResources().getDrawable(R.drawable.icon_list_divider));
    } else {
        listView.setDivider(mContext.getResources().getDrawable(R.drawable.icon_list_divider_light));
    }

    listView.setDividerHeight(1);

    //KitKat translucent navigation/status bar.
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        int topPadding = Common.getStatusBarHeight(mContext);

        //Calculate navigation bar height.
        int navigationBarHeight = 0;
        int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            navigationBarHeight = getResources().getDimensionPixelSize(resourceId);
        }

        if (rootView != null) {
            rootView.setPadding(0, topPadding, 0, 0);
        }

        listView.setClipToPadding(false);
        listView.setPadding(0, 0, 0, navigationBarHeight);
    }

    rootDir = mApp.getSharedPreferences().getString("DEFAULT_FOLDER",
            Environment.getExternalStorageDirectory().getPath());
    currentDir = rootDir;
    mHandler.postDelayed(new Runnable() {

        @Override
        public void run() {
            slideUpListView();
        }

    }, 250);
    return rootView;
}

From source file:org.rm3l.ddwrt.fragments.DDWRTBaseFragment.java

@NotNull
private ViewGroup getLayout() {
    @NotNull//from w  w  w.  j  a  va2  s.  com
    final LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    params.setMargins(margin, margin, margin, margin);

    boolean atLeastOneTileAdded = false;

    final SherlockFragmentActivity sherlockActivity = getSherlockActivity();
    if (this.fragmentTiles != null && !this.fragmentTiles.isEmpty()) {

        @NotNull
        final List<CardView> cards = new ArrayList<CardView>();

        final CardView.LayoutParams cardViewLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);

        final int themeBackgroundColor = getThemeBackgroundColor(sherlockActivity, router.getUuid());

        final boolean isThemeLight = isThemeLight(sherlockActivity, themeBackgroundColor);

        for (@NotNull
        final DDWRTTile ddwrtTile : this.fragmentTiles) {
            @Nullable
            final ViewGroup viewGroupLayout = ddwrtTile.getViewGroupLayout();
            atLeastOneTileAdded |= (viewGroupLayout != null);

            if (viewGroupLayout == null) {
                continue;
            }

            if (isThemeLight) {
                ((TextView) viewGroupLayout.findViewById(ddwrtTile.getTileTitleViewId()))
                        .setTextColor(getResources().getColor(android.R.color.holo_blue_dark));
            }

            //Detach this from Parent
            final ViewParent parent = viewGroupLayout.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(viewGroupLayout);
            }

            viewGroupLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));

            final CardView cardView = new CardView(sherlockActivity);
            cardView.setOnClickListener(ddwrtTile);
            cardView.setLayoutParams(cardViewLayoutParams);
            cardView.setCardBackgroundColor(themeBackgroundColor);
            //Add padding to CardView on v20 and before to prevent intersections between the Card content and rounded corners.
            cardView.setPreventCornerOverlap(true);
            //Add padding in API v21+ as well to have the same measurements with previous versions.
            cardView.setUseCompatPadding(true);

            cardView.addView(viewGroupLayout);

            cards.add(cardView);
        }

        atLeastOneTileAdded = (!cards.isEmpty());

        Log.d(LOG_TAG, "atLeastOneTileAdded: " + atLeastOneTileAdded + ", rows: " + cards.size());

        if (atLeastOneTileAdded) {
            //Drop Everything
            //                viewGroup.removeAllViews();

            mLayout = (LinearLayout) viewGroup.findViewById(R.id.tiles_container_scrollview_layout);

            for (@NotNull
            final CardView card : cards) {
                //                    mTableLayout.removeView(row);
                mLayout.addView(card);
            }

        }

        ((ScrollView) viewGroup).setFillViewport(true);
    }

    if (viewGroup == null || !atLeastOneTileAdded) {
        viewGroup = new FrameLayout(sherlockActivity);
        @NotNull
        final TextView view = new TextView(sherlockActivity);
        view.setGravity(Gravity.CENTER);
        view.setText(getResources().getString(R.string.no_data));
        view.setBackgroundResource(R.drawable.background_card);
        view.setLayoutParams(params);

        viewGroup.addView(view);
    }

    viewGroup.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    viewGroup.setLayoutParams(params);

    return viewGroup;

}

From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java

private void styleInfoSnackbar() {
    ViewGroup group = (ViewGroup) snackbar.getView();
    group.setBackgroundColor(getResources().getColor(R.color.primary));
    snackbar.setActionTextColor(getResources().getColor(R.color.accent));
    TextView tv = (TextView) group.findViewById(android.support.design.R.id.snackbar_text);
    tv.setTextColor(getResources().getColor(R.color.text_on_primary));
}

From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java

private void styleErrorSnackbar() {
    ViewGroup group = (ViewGroup) snackbar.getView();
    group.setBackgroundColor(getResources().getColor(android.R.color.holo_red_light));
    snackbar.setActionTextColor(getResources().getColor(R.color.white));
    TextView tv = (TextView) group.findViewById(android.support.design.R.id.snackbar_text);
    tv.setTextColor(getResources().getColor(R.color.white));
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@SuppressWarnings("NewApi")
private android.animation.Animator animateRevealColorFromCoordinates(ViewGroup viewRoot, @ColorRes int color,
        int x, int y) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    android.animation.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();/*from   w  ww . j  av a  2  s.com*/
    return anim;
}

From source file:com.juick.android.MainActivity.java

private static void restyleViewGroup(ViewGroup view, ColorsTheme.ColorTheme colorTheme, boolean pressed,
        boolean selected, boolean dontBackground) {
    ViewGroup parent = view;
    if (parent.getId() == R.id.navigation_panel)
        return;//from   w  ww.  j ava2 s. c  o m
    int childCount = parent.getChildCount();
    int background = colorTheme.getBackground(pressed);
    int foreground = colorTheme.getForeground(pressed);
    if (selected) {
        background = calculatePressedBackground(background, foreground);
    }
    if (!dontBackground) {
        boolean skipDraw = false;
        if ((view instanceof LinearLayout || view instanceof FrameLayout || view instanceof RelativeLayout)) {
            Context context = view.getContext();
            if (context instanceof MainActivity || context instanceof MessagesActivity
                    || context instanceof ThreadActivity) {
                // no unneeded background in given scrolling activities
                skipDraw = true;
                if (view.getBackground() != null) {
                    // but enable for layouts that with color
                    skipDraw = false;
                }
                if (!skipDraw && view.getClass().getName().toLowerCase().contains("decorview")) {
                    // given activities manage themselves
                    skipDraw = true;
                }
            }
        }
        if (!skipDraw)
            parent.setBackgroundColor(background);
    }
    if (view instanceof ListView)
        dontBackground = true;
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        restyleChildrenOrWidget(child, dontBackground);
    }
}

From source file:org.telegram.ui.PassportActivity.java

private void createEmailVerificationInterface(Context context) {
    actionBar.setTitle(LocaleController.getString("PassportEmail", R.string.PassportEmail));

    inputFields = new EditTextBoldCursor[1];
    for (int a = 0; a < 1; a++) {
        ViewGroup container = new FrameLayout(context);
        linearLayout2.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
        container.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));

        inputFields[a] = new EditTextBoldCursor(context);
        inputFields[a].setTag(a);/*from  ww w  . j  av a 2  s  . c  o  m*/
        inputFields[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        inputFields[a].setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
        inputFields[a].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        inputFields[a].setBackgroundDrawable(null);
        inputFields[a].setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        inputFields[a].setCursorSize(AndroidUtilities.dp(20));
        inputFields[a].setCursorWidth(1.5f);
        inputFields[a].setInputType(InputType.TYPE_CLASS_PHONE);

        inputFields[a].setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        switch (a) {
        case FIELD_EMAIL:
            inputFields[a].setHint(LocaleController.getString("PassportEmailCode", R.string.PassportEmailCode));
            break;
        }
        inputFields[a].setSelection(inputFields[a].length());
        inputFields[a].setPadding(0, 0, 0, AndroidUtilities.dp(6));
        inputFields[a].setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        container.addView(inputFields[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 21, 12, 21, 6));

        inputFields[a].setOnEditorActionListener((textView, i, keyEvent) -> {
            if (i == EditorInfo.IME_ACTION_DONE || i == EditorInfo.IME_ACTION_NEXT) {
                doneItem.callOnClick();
                return true;
            }
            return false;
        });

        inputFields[a].addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (ignoreOnTextChange) {
                    return;
                }
                if (emailCodeLength != 0 && inputFields[FIELD_EMAIL].length() == emailCodeLength) {
                    doneItem.callOnClick();
                }
            }
        });
    }

    bottomCell = new TextInfoPrivacyCell(context);
    bottomCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom,
            Theme.key_windowBackgroundGrayShadow));
    bottomCell.setText(LocaleController.formatString("PassportEmailVerifyInfo",
            R.string.PassportEmailVerifyInfo, currentValues.get("email")));
    linearLayout2.addView(bottomCell,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}