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:com.commit451.springy.CompanionWatchFaceConfigActivity.java

private void updatePreviewView(Themes.Theme theme, ViewGroup clockContainerView) {
    if (theme == Themes.MUZEI_THEME) {
        if (mMuzeiLoadedArtwork != null) {
            ((ImageView) clockContainerView.findViewById(R.id.background_image))
                    .setImageBitmap(mMuzeiLoadedArtwork.bitmap);
        }//from   ww w . j  a v a  2s  . co m
        clockContainerView.setBackgroundColor(Color.BLACK);
    } else {
        ((ImageView) clockContainerView.findViewById(R.id.background_image)).setImageDrawable(null);
        clockContainerView.setBackgroundColor(theme.color);
    }
}

From source file:com.google.android.apps.iosched.ui.MyScheduleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_empty_container, container,
            false);/*from  w  w w  .j a v a2 s.com*/
    inflater.inflate(R.layout.empty_waiting_for_sync, (ViewGroup) root.findViewById(android.R.id.empty), true);
    root.setBackgroundColor(Color.WHITE);
    ListView listView = (ListView) root.findViewById(android.R.id.list);
    listView.setItemsCanFocus(true);
    listView.setCacheColorHint(Color.WHITE);
    listView.setSelector(android.R.color.transparent);
    //listView.setEmptyView(root.findViewById(android.R.id.empty));
    return root;
}

From source file:jahirfiquitiva.iconshowcase.activities.ViewerActivity.java

private void showNotConnectedSnackBar() {
    Snackbar notConnectedSnackBar = Snackbar.make(layout, R.string.no_conn_title, Snackbar.LENGTH_LONG);

    final int snackbarLight = ContextCompat.getColor(context, R.color.snackbar_light);
    final int snackbarDark = ContextCompat.getColor(context, R.color.snackbar_dark);
    ViewGroup snackbarView = (ViewGroup) notConnectedSnackBar.getView();
    snackbarView.setBackgroundColor(ThemeUtils.darkTheme ? snackbarDark : snackbarLight);
    notConnectedSnackBar.show();/*  w  w w  . ja v a  2  s.  c  o  m*/
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mThisInstance = this;
    if (container == null) {
        return null;
    } else {//from  www .  jav  a2 s .c o  m
        container.setBackgroundColor(getResources().getColor(android.R.color.background_light));

        // get the arguments
        final String appname;
        String description;
        String startDate, endDate, apkVersion;
        ArrayList<Integer> sensors;

        // if this gets started as a fragment
        if (savedInstanceState == null) {
            Log.d(LOG_TAG, "savedInstance == null");
            savedInstanceState = getArguments();
            Log.d(LOG_TAG, "NOW savedInstance = " + savedInstanceState);
        }

        // supposed to show a placeholder?
        String placeholder = savedInstanceState.getString("de.da_sense.moses.client.placeholder");
        if (placeholder != null && placeholder.equals("yes")) {
            // inflate the placeholder
            Log.d(LOG_TAG, "onCreateView about to inflate PLACEHOLDER");
            mDetailFragmentView = inflater.inflate(R.layout.app_info_placeholder, container, false);
        } else { // normal display of details
            // retrieve the arguments
            mIndex = savedInstanceState.getInt("de.da_sense.moses.client.index");
            mBelongsTo = savedInstanceState.getInt(WelcomeActivity.KEY_BELONGS_TO);
            appname = savedInstanceState.getString("de.da_sense.moses.client.appname");
            description = savedInstanceState.getString("de.da_sense.moses.client.description");
            sensors = savedInstanceState.getIntegerArrayList("de.da_sense.moses.client.sensors");
            mAPKID = savedInstanceState.getString(ExternalApplication.KEY_APK_ID);
            apkVersion = savedInstanceState.getString("de.da_sense.moses.client.apkVersion");
            startDate = savedInstanceState.getString("de.da_sense.moses.client.startDate");
            endDate = savedInstanceState.getString("de.da_sense.moses.client.endDate");

            Log.d(LOG_TAG,
                    "\nretrieved index = " + mIndex + "\nretrieved belongsTo = " + mBelongsTo
                            + "\nretrieved appname = " + appname + "\nretireved description = " + description
                            + "\nretireved sensors = " + sensors + "\nretireved apkid = " + mAPKID
                            + "\nretireved startDate = " + startDate + "\nretireved endDate = " + endDate
                            + "\nretireved apkVersion = " + apkVersion);

            if (appname != null) {
                // inflate the detail view
                Log.d(LOG_TAG, "onCreateView about to inflate View");
                mDetailFragmentView = inflater.inflate(R.layout.app_info, container, false);
                // insert app name
                TextView t = (TextView) mDetailFragmentView.findViewById(R.id.usname);
                t.setText(appname);
                // insert description
                t = (TextView) mDetailFragmentView.findViewById(R.id.description);
                t.setMovementMethod(ScrollingMovementMethod.getInstance());
                t.setText(description);
                t = (TextView) mDetailFragmentView.findViewById(R.id.tv_us_startdate);
                t.setText(startDate);
                t = (TextView) mDetailFragmentView.findViewById(R.id.tv_us_enddate);
                t.setText(endDate);
                t = (TextView) mDetailFragmentView.findViewById(R.id.tv_us_apkversion);
                t.setText(apkVersion);
            } else {
                Log.e(LOG_TAG, "User study's informations are missing");
                return null;
            }
        }

        return mDetailFragmentView;
    }
}

From source file:net.nurik.roman.formwatchface.CompanionWatchFaceConfigActivity.java

private void updatePreviewView(Theme theme, ViewGroup clockContainerView, FormClockView clockView) {
    if (theme == Themes.MUZEI_THEME) {
        if (mMuzeiLoadedArtwork != null) {
            ((ImageView) clockContainerView.findViewById(R.id.background_image))
                    .setImageBitmap(mMuzeiLoadedArtwork.bitmap);
            clockView.setColors(mMuzeiLoadedArtwork.color1, mMuzeiLoadedArtwork.color2, Color.WHITE);
        }/*from   w  w  w  .ja va2s  .co m*/
        clockContainerView.setBackgroundColor(Color.BLACK);
    } else {
        ((ImageView) clockContainerView.findViewById(R.id.background_image)).setImageDrawable(null);
        final Resources res = getResources();
        clockView.setColors(res.getColor(theme.lightRes), res.getColor(theme.midRes), Color.WHITE);
        clockContainerView.setBackgroundColor(res.getColor(theme.darkRes));
    }
}

From source file:jahirfiquitiva.iconshowcase.activities.ViewerActivity.java

private void saveWallpaper(final Activity context, final String wallName, final MaterialDialog downloadDialog,
        final Bitmap result) {
    downloadDialog.setContent(context.getString(R.string.saving_wallpaper));
    new Thread(new Runnable() {
        @Override//from   w  w w  .  j a  v a 2s .  c  o m
        public void run() {
            if (mPrefs.getDownloadsFolder() != null) {
                downloadsFolder = new File(mPrefs.getDownloadsFolder());
            } else {
                downloadsFolder = new File(context.getString(R.string.walls_save_location,
                        Environment.getExternalStorageDirectory().getAbsolutePath()));
            }
            //noinspection ResultOfMethodCallIgnored
            downloadsFolder.mkdirs();
            final File destFile = new File(downloadsFolder, wallName + ".png");
            String snackbarText;
            if (!destFile.exists()) {
                try {
                    result.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(destFile));
                    snackbarText = context.getString(R.string.wallpaper_downloaded, destFile.getAbsolutePath());
                } catch (final Exception e) {
                    snackbarText = context.getString(R.string.error);
                }
            } else {
                snackbarText = context.getString(R.string.wallpaper_downloaded, destFile.getAbsolutePath());
            }
            final String finalSnackbarText = snackbarText;
            context.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    downloadDialog.dismiss();

                    if (toHide1 != null && toHide2 != null) {
                        toHide1.setVisibility(View.GONE);
                        toHide2.setVisibility(View.GONE);
                    }

                    Snackbar longSnackbar = Snackbar.make(layout, finalSnackbarText, Snackbar.LENGTH_LONG);
                    final int snackbarLight = ContextCompat.getColor(context, R.color.snackbar_light);
                    final int snackbarDark = ContextCompat.getColor(context, R.color.snackbar_dark);
                    ViewGroup snackbarView = (ViewGroup) longSnackbar.getView();
                    snackbarView.setBackgroundColor(ThemeUtils.darkTheme ? snackbarDark : snackbarLight);
                    longSnackbar.show();
                    longSnackbar.setCallback(new Snackbar.Callback() {
                        @Override
                        public void onDismissed(Snackbar snackbar, int event) {
                            super.onDismissed(snackbar, event);
                            if (toHide1 != null && toHide2 != null) {
                                toHide1.setVisibility(View.VISIBLE);
                                toHide2.setVisibility(View.VISIBLE);
                            }
                        }
                    });
                }
            });
        }
    }).start();
}

From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_empty_container, container,
            false);/*ww w  .j  a  va2s . co  m*/
    inflater.inflate(R.layout.empty_waiting_for_sync, (ViewGroup) root.findViewById(android.R.id.empty), true);
    root.setBackgroundColor(Color.WHITE);
    ListView listView = (ListView) root.findViewById(android.R.id.list);
    listView.setItemsCanFocus(true);
    listView.setCacheColorHint(Color.WHITE);
    listView.setSelector(android.R.color.transparent);

    return root;
}

From source file:org.rm3l.ddwrt.fragments.status.StatusWirelessFragment.java

/**
 * Called when a previously created loader has finished its load.  Note
 * that normally an application is <em>not</em> allowed to commit fragment
 * transactions while in this call, since it can happen after an
 * activity's state is saved.  See {@link android.support.v4.app.FragmentManager#beginTransaction()
 * FragmentManager.openTransaction()} for further discussion on this.
 * <p/>//  ww  w . j av  a2 s. c o  m
 * <p>This function is guaranteed to be called prior to the release of
 * the last data that was supplied for this Loader.  At this point
 * you should remove all use of the old data (since it will be released
 * soon), but should not do your own release of the data since its Loader
 * owns it and will take care of that.  The Loader will take care of
 * management of its data so you don't have to.  In particular:
 * <p/>
 * <ul>
 * <li> <p>The Loader will monitor for changes to the data, and report
 * them to you through new calls here.  You should not monitor the
 * data yourself.  For example, if the data is a {@link android.database.Cursor}
 * and you place it in a {@link android.widget.CursorAdapter}, use
 * the {@link android.widget.CursorAdapter#CursorAdapter(android.content.Context,
 * android.database.Cursor, int)} constructor <em>without</em> passing
 * in either {@link android.widget.CursorAdapter#FLAG_AUTO_REQUERY}
 * or {@link android.widget.CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER}
 * (that is, use 0 for the flags argument).  This prevents the CursorAdapter
 * from doing its own observing of the Cursor, which is not needed since
 * when a change happens you will get a new Cursor throw another call
 * here.
 * <li> The Loader will release the data once it knows the application
 * is no longer using it.  For example, if the data is
 * a {@link android.database.Cursor} from a {@link android.content.CursorLoader},
 * you should not call close() on it yourself.  If the Cursor is being placed in a
 * {@link android.widget.CursorAdapter}, you should use the
 * {@link android.widget.CursorAdapter#swapCursor(android.database.Cursor)}
 * method so that the old Cursor is not closed.
 * </ul>
 *
 * @param loader The Loader that has finished.
 * @param tiles  The data generated by the Loader.
 */
@Override
public void onLoadFinished(final Loader<Collection<DDWRTTile>> loader,
        @Nullable final Collection<DDWRTTile> tiles) {
    Log.d(LOG_TAG, "Done loading background task for " + StatusWirelessFragment.class.getCanonicalName());
    this.mIfaceTiles = tiles;

    if (viewGroup == null || tiles == null || tiles.isEmpty()) {
        return;
    }

    final SherlockFragmentActivity sherlockActivity = getSherlockActivity();

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

    final LinearLayout dynamicTilessViewGroup = (LinearLayout) viewGroup
            .findViewById(R.id.tiles_container_scrollview_layout_dynamic_items);

    //Remove everything first
    dynamicTilessViewGroup.removeAllViews();

    for (@NotNull
    final DDWRTTile tile : tiles) {
        @Nullable
        final ViewGroup tileViewGroupLayout = tile.getViewGroupLayout();
        if (tileViewGroupLayout == null) {
            continue;
        }

        if (isThemeLight) {
            final View titleView = tileViewGroupLayout.findViewById(tile.getTileTitleViewId());
            if (titleView instanceof TextView) {
                ((TextView) titleView).setTextColor(getResources().getColor(android.R.color.holo_blue_dark));
            }
        }

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

        //Init loaders for these tiles
        getSherlockActivity().getSupportLoaderManager()
                .initLoader(Long.valueOf(Utils.getNextLoaderId()).intValue(), null, tile);

        //Add row for this iface
        final CardView cardView = new CardView(sherlockActivity);
        cardView.setCardBackgroundColor(themeBackgroundColor);

        cardView.setOnClickListener(tile);
        tileViewGroupLayout.setOnClickListener(tile);

        cardView.addView(tileViewGroupLayout);

        //Remove view prior to adding it again to parent
        dynamicTilessViewGroup.addView(cardView);
    }

    //Make it visible now
    dynamicTilessViewGroup.setVisibility(View.VISIBLE);

}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

public void updateBackgroundSelectDays() {
    if (startDay != null && endDay != null) {
        Calendar auxCalendar = Calendar.getInstance(locale);
        auxCalendar.setTime(currentCalendar.getTime());
        auxCalendar.set(Calendar.DAY_OF_MONTH, 1);
        auxCalendar.set(Calendar.HOUR_OF_DAY, 0);
        auxCalendar.set(Calendar.MINUTE, 0); // set minute in hour
        auxCalendar.set(Calendar.SECOND, 0); // set second in minute
        auxCalendar.set(Calendar.MILLISECOND, 0);
        Calendar startCalendar = getCurrentCalendar();
        startCalendar.setTime(startDay);
        Calendar endCalendar = getCurrentCalendar();
        endCalendar.setTime(endDay);/* w  w  w.j  a v a  2s.  co  m*/
        if (auxCalendar.compareTo(endCalendar) > 0)
            return;
        if (auxCalendar.compareTo(startCalendar) > 0) {
            startCalendar = auxCalendar;
            if (startCalendar.compareTo(endCalendar) != 0) {
                ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
                startDayOfMonthBackground.setBackgroundColor(
                        ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                TextView dayOfMonth = getDayOfMonthText(startCalendar);
                dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
            }
            int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            Calendar endDayOnMonthCalendar = Calendar.getInstance(locale);
            endDayOnMonthCalendar.setTime(auxCalendar.getTime());
            endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth);
            if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) {
                endCalendar = endDayOnMonthCalendar;
                ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                endDayOfMonthBackground.setBackgroundColor(
                        ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                TextView dayOfMonth = getDayOfMonthText(endCalendar);
                dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
            } else {
                ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right);
                TextView dayOfMonth = getDayOfMonthText(endCalendar);
                dayOfMonth
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                ViewGroup dayOfMonthBackground = getDayOfMonthBackground(endCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
            }
        } else {
            int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            Calendar endDayOnMonthCalendar = Calendar.getInstance(locale);
            endDayOnMonthCalendar.setTime(auxCalendar.getTime());
            endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth);
            if (endDayOnMonthCalendar.compareTo(startCalendar) < 0)
                return;
            if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) {
                endCalendar = endDayOnMonthCalendar;
                if (startCalendar.compareTo(endCalendar) != 0) {
                    ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                    endDayOfMonthBackground.setBackgroundColor(
                            ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                    TextView dayOfMonth = getDayOfMonthText(endCalendar);
                    dayOfMonth
                            .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
                }
                ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
                startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left);
                ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);

            } else {
                int compare = startCalendar.compareTo(endCalendar);//compare startdate and enddate, if they are equal, just draw circle not draw background startdate and enddate
                ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
                if (compare != 0)
                    startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left);
                ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
                ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                if (compare != 0)
                    endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right);
                dayOfMonthBackground = getDayOfMonthBackground(endCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
                TextView dayOfMonth = getDayOfMonthText(endCalendar);
                dayOfMonth
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                dayOfMonth = getDayOfMonthText(startCalendar);
                dayOfMonth
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
            }

        }
        String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startCalendar.getTime());
        int days = getDays(startCalendar, endCalendar);

        for (int i = 1; i < days; i++) {
            startCalendar.add(Calendar.DAY_OF_YEAR, 1);
            ViewGroup dayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
            TextView dayOfMonth = getDayOfMonthText(startCalendar);
            if (dayOfMonth.getVisibility() != View.VISIBLE)
                continue;
            dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
            dayOfMonthBackground.setBackgroundColor(
                    ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
        }
    } else {
        if (startDay != null) {
            Calendar startDayOnMonthCalendar = Calendar.getInstance(locale);
            startDayOnMonthCalendar.setTime(currentCalendar.getTime());
            startDayOnMonthCalendar.set(Calendar.DAY_OF_MONTH, 1);
            startDayOnMonthCalendar.set(Calendar.HOUR_OF_DAY, 0);
            startDayOnMonthCalendar.set(Calendar.MINUTE, 0); // set minute in hour
            startDayOnMonthCalendar.set(Calendar.SECOND, 0); // set second in minute
            startDayOnMonthCalendar.set(Calendar.MILLISECOND, 0);

            Calendar endDayOnMonthCalendar = Calendar.getInstance(locale);
            endDayOnMonthCalendar.setTime(startDayOnMonthCalendar.getTime());
            int totalDaysInMonth = startDayOnMonthCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth);
            Calendar startCalendar = getCurrentCalendar();
            startCalendar.setTime(startDay);
            if (startCalendar.compareTo(startDayOnMonthCalendar) >= 0
                    && startCalendar.compareTo(endDayOnMonthCalendar) <= 0) {
                selectStartDay(startDay);
            }
        }
    }

}

From source file:com.cw.litenote.note.Note.java

@Override
public void finish() {
    System.out.println("Note / _finish");
    if (mPagerHandler != null)
        mPagerHandler.removeCallbacks(mOnBackPressedRun);

    ViewGroup view = (ViewGroup) getWindow().getDecorView();
    view.setBackgroundColor(getResources().getColor(color.background_dark)); // avoid white flash
    view.removeAllViews();//from  w  ww.j a v  a2  s.  c  om

    super.finish();
}