Example usage for android.view View setBackgroundColor

List of usage examples for android.view View setBackgroundColor

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:de.azapps.mirakel.main_activity.MainActivity.java

public void setCurrentList(final ListMirakel currentList, final View currentView, final boolean switchFragment,
        final boolean resetGoBackTo) {
    if (currentList == null) {
        return;//w  w w  .j  ava2  s . c om
    }
    if (resetGoBackTo) {
        this.goBackTo.clear();
    }
    this.currentList = currentList;
    if (this.mDrawerLayout != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                MainActivity.this.mDrawerLayout.closeDrawers();
            }
        });
    }
    final Optional<Task> taskOptional = currentList.getFirstTask();
    if (taskOptional.isPresent()) {
        this.currentTask = taskOptional.get();
    } else {
        this.currentTask = Task.getDummy(getApplicationContext(), getCurrentList());
    }
    if (getTasksFragment() != null) {
        getTasksFragment().updateList();
        if (switchFragment) {
            getTasksFragment().setScrollPosition(0);
            setCurrentItem(MainActivity.getTasksFragmentPosition());
        }
    }
    final View currentViewL = getCurrentView(currentView);
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if ((currentViewL != null) && MirakelCommonPreferences.highlightSelected()) {
                clearHighlighted();
                if (MainActivity.this.oldClickedList != null) {
                    MainActivity.this.oldClickedList.setSelected(false);
                    MainActivity.this.oldClickedList.setBackgroundColor(0x00000000);
                }
                currentViewL.setBackgroundColor(getResources().getColor(R.color.pressed_color));
                MainActivity.this.oldClickedList = currentViewL;
            }
        }
    });
    if (switchFragment) {
        setCurrentTask(this.currentTask);
    }
    if (this.currentPosition == getTasksFragmentPosition()) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (getActionBar() != null) {
                    getActionBar().setTitle(MainActivity.this.currentList.getName());
                }
            }
        });
    }
}

From source file:com.sonvp.tooltip.Tooltip.java

private View getViewTooltip(Builder builder, int backgroundColor) {

    View toolTip = null;

    if (builder.viewTooltip == null) {
        TextView text = new TextView(builder.context);
        text.setPadding((int) builder.leftPadding, (int) builder.topPadding, (int) builder.rightPadding,
                (int) builder.bottomPadding);
        text.setGravity(builder.textGravity);
        text.setTextColor(builder.textColor);
        text.setTextSize(TypedValue.COMPLEX_UNIT_PX, builder.textSize);
        text.setTypeface(builder.typeface, builder.typefaceStyle);
        int lines = builder.lines;
        if (lines > 0) {
            text.setLines(lines);// w  ww  .  ja  v a  2 s  . c o m
            text.setEllipsize(TextUtils.TruncateAt.END);
        }

        CharSequence txt = builder.text;
        if (TextUtils.isEmpty(txt)) {
            txt = builder.context.getString(builder.textResourceId);
        }
        text.setText(txt);
        toolTip = text;

    } else {
        toolTip = builder.viewTooltip;
    }

    float radius = builder.radius;
    if (radius > 0.0F) {
        GradientDrawable drawable = new GradientDrawable();
        drawable.setColor(backgroundColor);
        drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
        drawable.setCornerRadius(radius);

        //noinspection deprecation
        toolTip.setBackgroundDrawable(drawable);
    } else {
        toolTip.setBackgroundColor(backgroundColor);
    }

    return toolTip;
}

From source file:com.dycody.android.idealnote.DetailFragment.java

/**
 * Colors tag marker in note's title and content elements
 *//*from ww w. j  ava2s . com*/
private void setTagMarkerColor(Category tag) {

    String colorsPref = prefs.getString("settings_colors_app", Constants.PREF_COLORS_APP_DEFAULT);

    // Checking preference
    if (!"disabled".equals(colorsPref)) {

        // Choosing target view depending on another preference
        ArrayList<View> target = new ArrayList<>();
        if ("complete".equals(colorsPref)) {
            target.add(titleWrapperView);
            target.add(scrollView);
        } else {
            target.add(tagMarkerView);
        }

        // Coloring the target
        if (tag != null && tag.getColor() != null) {
            for (View view : target) {
                view.setBackgroundColor(parseInt(tag.getColor()));
            }
        } else {
            for (View view : target) {
                view.setBackgroundColor(Color.parseColor("#00000000"));
            }
        }
    }
}

From source file:com.yadadeya.yadadeya.widget.SlidingTabLayout.java

public void populateTabStrip(int frCount, int selectedFr) {
    // final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < frCount; i++) {
        View tabView = null;
        TextView tabTitleView = null;/*from  w ww. j a  v  a 2s .  c  o m*/

        ImageView tabIconView = null;

        /*if (mTabViewLayoutId != 0) {
        // If there is a custom tab view layout id set, try and inflate it
        tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip,
                false);
        tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }
                
        if (tabView == null) {
        tabView = createDefaultTabView(getContext());
        }
                
        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
        tabTitleView = (TextView) tabView;
        }*/

        /* if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
         }*/

        if (tabView == null) {
            tabView = createDefaultImageView(getContext());
        }

        if (tabIconView == null && ImageView.class.isInstance(tabView)) {
            tabIconView = (ImageView) tabView;
        }

        tabIconView.setImageDrawable(getResources().getDrawable(getDrawableId(i)));
        if (selectedFr == i) {
            tabIconView.setSelected(true);
        }

        //tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        if (i == 2) {
            tabView.setEnabled(false);
            //tabView.setBackgroundColor(getResources().getColor(R.color.guillotine_background));

        }

        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == selectedFr) {
            tabView.setSelected(true);
            tabView.setBackgroundColor(Color.parseColor("#40000000"));
        }
    }
}

From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorSongsMultiselectAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Cursor c = (Cursor) getItem(position);
    SongsListViewHolder holder = null;//w  w w . jav  a 2s . com

    if (convertView == null) {

        convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_songs_layout, parent,
                false);
        holder = new SongsListViewHolder();
        holder.image = (ImageView) convertView.findViewById(R.id.songThumbnailMusicLibraryEditor);
        holder.title = (TextView) convertView.findViewById(R.id.songNameMusicLibraryEditor);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.songCheckboxMusicLibraryEditor);
        holder.subText = (TextView) convertView.findViewById(R.id.artistNameSongListView);

        convertView.setTag(holder);
    } else {
        holder = (SongsListViewHolder) convertView.getTag();
    }

    final View finalConvertView = convertView;
    final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
    final String songTitle = c.getString(c.getColumnIndex(DBAccessHelper.SONG_TITLE));
    String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
    String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));

    holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    holder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.subText
            .setPaintFlags(holder.subText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    //Set the songID as the view's tag.
    convertView.setTag(R.string.song_id, songId);

    //Set the song title.
    holder.title.setText(songTitle);
    holder.subText.setText(songArtist);
    mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image,
            PlaylistEditorActivity.displayImageOptions);

    //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
    if (PlaylistEditorActivity.songDBIdsList.contains(songId)) {
        convertView.setBackgroundColor(0xCC0099CC);
        holder.checkBox.setChecked(true);
    } else {
        convertView.setBackgroundColor(0x00000000);
        holder.checkBox.setChecked(false);
    }

    holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {

            if (isChecked == true) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCC0099CC);
                    PlaylistEditorActivity.songDBIdsList.add(songId);
                }

            } else if (isChecked == false) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCC0099CC);
                    PlaylistEditorActivity.songDBIdsList.remove(songId);
                }

            }

        }

    });

    return convertView;
}

From source file:com.aniruddhc.acemusic.player.MusicLibraryEditorActivity.MusicLibraryEditorSongsMultiselectAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Cursor c = (Cursor) getItem(position);
    SongsListViewHolder holder = null;/*from   w  w w. j  a v a  2s .co  m*/

    if (convertView == null) {

        convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_songs_layout, parent,
                false);
        holder = new SongsListViewHolder();
        holder.image = (ImageView) convertView.findViewById(R.id.songThumbnailMusicLibraryEditor);
        holder.title = (TextView) convertView.findViewById(R.id.songNameMusicLibraryEditor);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.songCheckboxMusicLibraryEditor);
        holder.subText = (TextView) convertView.findViewById(R.id.artistNameSongListView);

        convertView.setTag(holder);
    } else {
        holder = (SongsListViewHolder) convertView.getTag();
    }

    final View finalConvertView = convertView;
    final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
    final String songTitle = c.getString(c.getColumnIndex(DBAccessHelper.SONG_TITLE));
    String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
    String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));

    holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    holder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.subText
            .setPaintFlags(holder.subText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    //Set the songID as the view's tag.
    convertView.setTag(R.string.song_id, songId);

    //Set the song title.
    holder.title.setText(songTitle);
    holder.subText.setText(songArtist);
    mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image,
            MusicLibraryEditorActivity.displayImageOptions);

    //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
    if (MusicLibraryEditorActivity.songDBIdsList.contains(songId)) {
        convertView.setBackgroundColor(0xCC0099CC);
        holder.checkBox.setChecked(true);
    } else {
        convertView.setBackgroundColor(0x00000000);
        holder.checkBox.setChecked(false);
    }

    holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {

            if (isChecked == true) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCC0099CC);
                    MusicLibraryEditorActivity.songDBIdsList.add(songId);
                }

            } else if (isChecked == false) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCC0099CC);
                    MusicLibraryEditorActivity.songDBIdsList.remove(songId);
                }

            }

        }

    });

    return convertView;
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

private View makeSimpleDivider() {
    float density = ResourceUtils.obtainDensity(context);
    if (C.API_LOLLIPOP) {
        FrameLayout frameLayout = new FrameLayout(context);
        View view = new View(context);
        view.setBackgroundResource(ResourceUtils.getResourceId(context, android.R.attr.listDivider, 0));
        frameLayout.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        frameLayout.setPadding(0, (int) (8f * density), 0, (int) (8f * density));
        return frameLayout;
    } else {//from  w w  w  .  j  a  va2 s  .c o m
        View view = new View(context);
        int[] attrs = { android.R.attr.listSeparatorTextViewStyle };
        TypedArray typedArray = context.obtainStyledAttributes(attrs);
        int style = typedArray.getResourceId(0, 0);
        typedArray.recycle();
        if (style != 0) {
            typedArray = context.obtainStyledAttributes(style, new int[] { android.R.attr.background });
            Drawable drawable = typedArray.getDrawable(0);
            typedArray.recycle();
            if (drawable != null) {
                view.setBackgroundColor(GraphicsUtils.getDrawableColor(context, drawable, Gravity.BOTTOM));
            }
        }
        view.setMinimumHeight((int) (2f * density));
        return view;
    }
}

From source file:com.binomed.showtime.android.screen.results.CineShowTimeResultsFragment.java

@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
    if (arg0.getId() == R.id.resultListResultNonExpandable) {
        if ((model.getNearResp() != null) && (model.getNearResp().getTheaterList() != null)) {
            int theaterListSize = model.getNearResp().getTheaterList().size();
            if (theaterListSize == position) {
                model.setStart(model.getStart() + 10);
                try {
                    interaction.getTracker().trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_RESULT // Category
                            , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action
                            , CineShowtimeCst.ANALYTICS_LABEL_RESULTS_MORE_RESULTS // Label
                            , 0 // Value
                    );//from   w  w  w  . ja v a  2 s . co m
                    launchNearService();
                } catch (UnsupportedEncodingException e) {
                    // TODO
                }
            } else {
                if (nonExpendable) {
                    if (resultListNonExpandable
                            .getChildAt(adapterNonExpendable.getSelectedPosition()) != null) {
                        resultListNonExpandable.getChildAt(adapterNonExpendable.getSelectedPosition())
                                .setBackgroundDrawable(null);
                    }
                    adapterNonExpendable.setSelectedPosition(position);
                    view.setBackgroundColor(R.color.select_color);
                }
                model.getGroupExpanded().clear();
                model.getGroupExpanded().add(position);
                if (!movieView) {
                    interaction.onTheaterClick(model.getNearResp().getTheaterList().get(position));
                } else if (nonExpendable) {
                    interaction.onMovieClick(adapterNonExpendable.getMovieList().get(position));
                }
            }
        }
    }

}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private void animateRevealHide(final View targetview, View startView) {
    if (isActionInsertOrEdit()) {
        int cx = startView.getLeft() + (startView.getWidth() / 2); //middle of button
        int cy = startView.getTop() + (startView.getHeight() / 2); //middle of button
        int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left

        Animator anim = ViewAnimationUtils.createCircularReveal(targetview, cx, cy, radius, 0);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override//from  ww w.j a va 2s.co m
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                targetview.setVisibility(View.INVISIBLE);
            }
        });
        //anim.setInterpolator(new AccelerateInterpolator());
        anim.setDuration(ANIM_DURATION);
        anim.start();

        Integer colorTo = getResources().getColor(R.color.primaryColor);
        Integer colorFrom = getResources().getColor(android.R.color.white);
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                targetview.setBackgroundColor((Integer) animator.getAnimatedValue());
            }

        });
        colorAnimation.setInterpolator(new AccelerateInterpolator(2));
        colorAnimation.setDuration(ANIM_DURATION);
        colorAnimation.start();
    } else if (isActionActionView()) {
        mAnimBackGroudView.animate().scaleX(1).scaleY(1).alpha(1).translationY(0).setDuration(ANIM_DURATION)
                .setInterpolator(new AccelerateInterpolator()).start();
        mNoteEditor.animate().alpha(0).setDuration(100).start();
    }
}

From source file:net.czlee.debatekeeper.DebatingActivity.java

/**
 * @param view a {@link View} which should often be the <code>RelativeLayout</code> in debate_timer_display.xml,
 * except in cases where no debate is loaded or something like that.
 * @param timeTextColour the text colour to use for the current time
 * @param backgroundColour the colour to use for the background
 *//*  w ww .j  a v a2  s.c o m*/
private void updateDebateTimerDisplayColours(View view, int timeTextColour, int backgroundColour) {

    boolean viewIsDebateTimerDisplay = view.getId() == R.id.debateTimer_root;

    switch (mBackgroundColourArea) {
    case TOP_BAR_ONLY:
        if (viewIsDebateTimerDisplay) {
            // These would only be expected to exist if the view given is the debate timer display
            view.findViewById(R.id.debateTimer_speechNameText).setBackgroundColor(backgroundColour);
            view.findViewById(R.id.debateTimer_periodDescriptionText).setBackgroundColor(backgroundColour);
        }
        break;
    case WHOLE_SCREEN:
        view.setBackgroundColor(backgroundColour);
        break;
    case DISABLED:
        // Do nothing
    }

    // This would only be expected to exist if the view given is the debate timer display
    if (viewIsDebateTimerDisplay)
        ((TextView) view.findViewById(R.id.debateTimer_currentTime)).setTextColor(timeTextColour);
}