Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.flexible.flexibleadapter.utils.DrawableUtils.java

/**
 * Generate the {@code ColorDrawable} object from the provided Color.
 *
 * @param color the color/*w w  w  . j  a va2 s .  c  om*/
 * @return the {@code ColorDrawable} object
 * @since 5.0.0-rc1
 */
public static ColorDrawable getColorDrawable(@ColorInt int color) {
    return new ColorDrawable(color);
}

From source file:com.citrus.sdk.CitrusActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setActionBarBackground() {
    // Set primary color
    if (mColorPrimary != null && mActionBar != null) {
        mActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(mColorPrimary)));
    }/* ww w  .ja  v a  2  s  . c o  m*/

    // Set action bar color. Available only on android version Lollipop or higher.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mColorPrimaryDark != null) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.parseColor(mColorPrimaryDark));
    }
}

From source file:com.android.together.BaseActivity.java

public void setBgAlpha(BasePopupWindow popuWindow) {
    if (popuWindow != null) {
        ColorDrawable cd = new ColorDrawable(0x000000);
        popuWindow.setBackgroundDrawable(cd);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = 0.4f;/*from ww w  .  j  ava 2  s  .co m*/
        getWindow().setAttributes(lp);
    } else {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = 1f;
        getWindow().setAttributes(lp);
    }
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

@Override
public void onPause() {
    super.onPause();
    actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
    // set the statusBar color
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}

From source file:com.mg.axe.androiddevelop.view.SearchViewLayout.java

@Override
protected void onFinishInflate() {
    mCollapsed = (ViewGroup) findViewById(R.id.search_box_collapsed);
    mSearchIcon = findViewById(R.id.search_magnifying_glass);
    mCollapsedSearchBox = findViewById(R.id.search_box_start_search);
    mCollapsedHintView = (TextView) findViewById(R.id.search_box_collapsed_hint);

    mExpanded = (ViewGroup) findViewById(R.id.search_expanded_root);
    mSearchEditText = (EditText) mExpanded.findViewById(R.id.search_expanded_edit_text);
    mBackButtonView = mExpanded.findViewById(R.id.search_expanded_back_button);
    mExpandedSearchIcon = findViewById(R.id.search_expanded_magnifying_glass);

    // Convert a long click into a click to expand the search box, and then long click on the
    // search view. This accelerates the long-press scenario for copy/paste.
    mCollapsedSearchBox.setOnLongClickListener(new OnLongClickListener() {
        @Override//  w  w w  .  j  a v  a  2  s.  c  o  m
        public boolean onLongClick(View view) {
            mCollapsedSearchBox.performClick();
            mSearchEditText.performLongClick();
            return false;
        }
    });

    mCollapsed.setOnClickListener(mSearchViewOnClickListener);
    mSearchIcon.setOnClickListener(mSearchViewOnClickListener);
    mCollapsedSearchBox.setOnClickListener(mSearchViewOnClickListener);

    mSearchEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                Utils.showInputMethod(v);
            } else {
                Utils.hideInputMethod(v);
            }
        }
    });
    mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                callSearchListener();
                Utils.hideInputMethod(v);
                return true;
            }
            return false;
        }
    });
    mSearchEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mSearchEditText.getText().length() > 0) {
                if (mExpandedSearchIcon.getVisibility() != View.VISIBLE) {
                    Utils.fadeIn(mExpandedSearchIcon, ANIMATION_DURATION);
                }
            } else {
                Utils.fadeOut(mExpandedSearchIcon, ANIMATION_DURATION);
            }
            if (mSearchBoxListener != null)
                mSearchBoxListener.onTextChanged(s, start, before, count);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            if (mSearchBoxListener != null)
                mSearchBoxListener.beforeTextChanged(s, start, count, after);
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mSearchBoxListener != null)
                mSearchBoxListener.afterTextChanged(s);
        }
    });

    mBackButtonView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            collapse();
        }
    });

    mExpandedSearchIcon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            callSearchListener();
            Utils.hideInputMethod(v);
        }
    });

    mCollapsedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.transparent));
    mExpandedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), R.color.default_color_expanded));
    mBackgroundTransition = new TransitionDrawable(new Drawable[] { mCollapsedDrawable, mExpandedDrawable });
    mBackgroundTransition.setCrossFadeEnabled(true);
    setBackgroundCompat();
    Utils.setPaddingAll(SearchViewLayout.this, 8);

    super.onFinishInflate();
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    fabSkin = PreferenceUtils.getAccentString(Sp);

    int th = Integer.parseInt(Sp.getString("theme", "0"));

    theme = th == 2 ? PreferenceUtils.hourOfDay() : th;

    // setting accent theme
    if (Build.VERSION.SDK_INT >= 21) {

        switch (fabSkin) {
        case "#F44336":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_red);
            else/*www. java 2 s.  c om*/
                setTheme(R.style.pref_accent_dark_red);
            break;

        case "#e91e63":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_pink);
            else
                setTheme(R.style.pref_accent_dark_pink);
            break;

        case "#9c27b0":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_purple);
            else
                setTheme(R.style.pref_accent_dark_purple);
            break;

        case "#673ab7":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_purple);
            else
                setTheme(R.style.pref_accent_dark_deep_purple);
            break;

        case "#3f51b5":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_indigo);
            else
                setTheme(R.style.pref_accent_dark_indigo);
            break;

        case "#2196F3":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue);
            else
                setTheme(R.style.pref_accent_dark_blue);
            break;

        case "#03A9F4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_blue);
            else
                setTheme(R.style.pref_accent_dark_light_blue);
            break;

        case "#00BCD4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_cyan);
            else
                setTheme(R.style.pref_accent_dark_cyan);
            break;

        case "#009688":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_teal);
            else
                setTheme(R.style.pref_accent_dark_teal);
            break;

        case "#4CAF50":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_green);
            else
                setTheme(R.style.pref_accent_dark_green);
            break;

        case "#8bc34a":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_green);
            else
                setTheme(R.style.pref_accent_dark_light_green);
            break;

        case "#FFC107":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_amber);
            else
                setTheme(R.style.pref_accent_dark_amber);
            break;

        case "#FF9800":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_orange);
            else
                setTheme(R.style.pref_accent_dark_orange);
            break;

        case "#FF5722":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_orange);
            else
                setTheme(R.style.pref_accent_dark_deep_orange);
            break;

        case "#795548":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_brown);
            else
                setTheme(R.style.pref_accent_dark_brown);
            break;

        case "#212121":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_black);
            else
                setTheme(R.style.pref_accent_dark_black);
            break;

        case "#607d8b":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue_grey);
            else
                setTheme(R.style.pref_accent_dark_blue_grey);
            break;

        case "#004d40":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_super_su);
            else
                setTheme(R.style.pref_accent_dark_super_su);
            break;
        }
    } else {
        if (theme == 1) {
            setTheme(R.style.appCompatDark);
        } else {
            setTheme(R.style.appCompatLight);
        }
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }
    selectItem(0);
}

From source file:com.hufeiya.SignIn.fragment.CategorySelectionFragment.java

private void setTeacherDrawer(JsonUser user) {
    // Create the AccountHeader
    AccountHeader headerResult = new AccountHeaderBuilder().withActivity(getActivity())
            .withHeaderBackground(new ColorDrawable(Color.BLUE))
            .addProfiles(new ProfileDrawerItem().withName(user.getUsername()).withEmail(user.getUserNo())
                    .withIcon(getResources().getDrawable(R.drawable.avatar_10)))
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
                @Override/*  w  ww  .  j  ava  2  s. c o  m*/
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
                    return false;
                }
            }).build();
    PrimaryDrawerItem index = new PrimaryDrawerItem().withName("");
    SecondaryDrawerItem studentSheetItem = new SecondaryDrawerItem().withName("???");

    //create the drawer and remember the `Drawer` result object
    drawer = new DrawerBuilder().withAccountHeader(headerResult).withActivity(getActivity())
            .addDrawerItems(index, new DividerDrawerItem(), studentSheetItem)
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    // do something with the clicked item :D
                    return true;
                }
            }).build();
}

From source file:com.cyanogenmod.eleven.ui.activities.BaseActivity.java

public void setupActionBar(String title) {
    setActionBarTitle(title);//from   w ww  . j  ava  2  s .co  m

    if (mActionBarBackground == null) {
        final int actionBarColor = getResources().getColor(R.color.header_action_bar_color);
        mActionBarBackground = new ColorDrawable(actionBarColor);
        mToolBar.setBackgroundDrawable(mActionBarBackground);
    }
}

From source file:com.jlabs.peepaid.searchviewlay.SearchViewLayout.java

@Override
protected void onFinishInflate() {
    mCollapsed = (ViewGroup) findViewById(R.id.search_box_collapsed);
    mSearchIcon = findViewById(R.id.search_magnifying_glass);
    mCollapsedSearchBox = findViewById(R.id.search_box_start_search);
    mCollapsedHintView = (TextView) findViewById(R.id.search_box_collapsed_hint);

    mExpanded = (ViewGroup) findViewById(R.id.search_expanded_root);
    mSearchEditText = (EditText) mExpanded.findViewById(R.id.search_expanded_edit_text);
    mBackButtonView = mExpanded.findViewById(R.id.search_expanded_back_button);
    mExpandedSearchIcon = findViewById(R.id.search_expanded_magnifying_glass);

    // Convert a long click into a click to expand the search box, and then long click on the
    // search view. This accelerates the long-press scenario for copy/paste.
    mCollapsedSearchBox.setOnLongClickListener(new OnLongClickListener() {
        @Override//from  w w  w.  ja va2  s .c  o m
        public boolean onLongClick(View view) {
            mCollapsedSearchBox.performClick();
            mSearchEditText.performLongClick();
            return false;
        }
    });

    mCollapsed.setOnClickListener(mSearchViewOnClickListener);
    mSearchIcon.setOnClickListener(mSearchViewOnClickListener);
    mCollapsedSearchBox.setOnClickListener(mSearchViewOnClickListener);

    mSearchEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                Utils.showInputMethod(v);
            } else {
                Utils.hideInputMethod(v);
            }
        }
    });
    mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                callSearchListener();
                Utils.hideInputMethod(v);
                return true;
            }
            return false;
        }
    });
    mSearchEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mSearchEditText.getText().length() > 0) {
                if (mExpandedSearchIcon.getVisibility() != View.VISIBLE) {
                    Utils.fadeIn(mExpandedSearchIcon, ANIMATION_DURATION);
                }
            } else {
                Utils.fadeOut(mExpandedSearchIcon, ANIMATION_DURATION);
            }
            if (mSearchBoxListener != null)
                mSearchBoxListener.onTextChanged(s, start, before, count);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            if (mSearchBoxListener != null)
                mSearchBoxListener.beforeTextChanged(s, start, count, after);
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mSearchBoxListener != null)
                mSearchBoxListener.afterTextChanged(s);
        }
    });

    mBackButtonView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            collapse();
        }
    });

    mExpandedSearchIcon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            callSearchListener();
            Utils.hideInputMethod(v);
        }
    });

    mCollapsedDrawable = new ColorDrawable(
            ContextCompat.getColor(getContext(), R.color.default_color_expanded));
    mExpandedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), R.color.default_color_expanded));
    mBackgroundTransition = new TransitionDrawable(new Drawable[] { mCollapsedDrawable, mExpandedDrawable });
    mBackgroundTransition.setCrossFadeEnabled(true);

    setBackground(mBackgroundTransition);
    Utils.setPaddingAll(SearchViewLayout.this, 8);

    super.onFinishInflate();
}

From source file:com.dsdar.thosearoundme.TeamViewActivity.java

/**
 * Method to initialize the components used in team activity
 *//*w w  w .  j a va  2 s.  c o m*/
@SuppressLint("NewApi")
private void initializeComponents() {

    itsActionBar = getActionBar();

    itsActionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    // itsActionBar.setDisplayShowTitleEnabled(false);
    itsActionBar.setDisplayShowTitleEnabled(true);
    itsActionBar.setTitle("Those Around Me");
    // itsActionBar.setCustomView(R.layout.invitation_count);
    // itsInvitationcount = (TextView) findViewById(R.id.text2);

    itsActionBar.setDisplayShowCustomEnabled(true);

    itsActionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor(ACTION_BAR_COLOR)));
    // LayoutInflater inflator = (LayoutInflater) this
    // .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //
    // View v = inflator.inflate(R.layout.invitation_count, null);
    itsActionBar.setCustomView(R.layout.invitation_count);
    itsInvitationcount = (TextView) findViewById(R.id.text2);
    itsActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    startRefreshTimer();
    // if (invite_count != null || invite_count != "") {
    // itsInvitationcount.setText(invite_count);
    // } else {
    // itsInvitationcount.setText("");
    // }

    itsNormalMapView = (TextView) findViewById(R.id.tvMainPageMapMap);
    itsSatelliteMapView = (TextView) findViewById(R.id.tvMainPageMapSatellite);
    itsHybridMapView = (TextView) findViewById(R.id.tvMainPageMapHybrid);
    itsTeamView = (TextView) findViewById(R.id.tvTeamActTeam);
    itsTeamView.setText("Team");
    itsHomeView = (TextView) findViewById(R.id.tvTeamActHome);
    itsFollowersView = (TextView) findViewById(R.id.tvTeamActFollowers);
    itsHomeImgBlack = getResources().getDrawable(R.drawable.home_icon_black);
    itsHomeImgBlack.setBounds(0, 0, imgBounds, imgBounds);
    itsHomeImgGreen = getResources().getDrawable(R.drawable.home_icon_green);
    itsHomeImgGreen.setBounds(0, 0, imgBounds, imgBounds);
    itsTeamImgGreen = getResources().getDrawable(R.drawable.team_icon_green);
    itsTeamImgGreen.setBounds(0, 0, imgBounds, imgBounds);
    itsTeamImgBlack = getResources().getDrawable(R.drawable.team_icon_black);
    itsTeamImgBlack.setBounds(0, 0, imgBounds, imgBounds);
    itsFollowerImgGreen = getResources().getDrawable(R.drawable.followers_icon_green);
    itsFollowerImgGreen.setBounds(0, 0, imgBounds, imgBounds);
    itsFollowerImgBlack = getResources().getDrawable(R.drawable.followers_icon_black);
    itsFollowerImgBlack.setBounds(0, 0, imgBounds, imgBounds);

    itsShowAllButton = (Button) findViewById(R.id.tvMainPageShowAllMembers);
    itsAddTeam = (Button) findViewById(R.id.tvAddTeam);
    itsAddTeamMember = (Button) findViewById(R.id.tvAddMember);
    itsTvMan = (Button) findViewById(R.id.tvMan);
    itsMyLoc = (Button) findViewById(R.id.btnMyLoc);
    itsStickyMarker = (Button) findViewById(R.id.btnStickyMarker);
    itsTvMan.setBackgroundResource(R.drawable.map_follow_me_no);
    itsGPSAlert = (TextView) findViewById(R.id.tvGpsAlert);
    SupportMapFragment aSupportMapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.TeamViewMap);
    itsGoogleMap = aSupportMapFragment.getMap();
    enableMapsPreference();
    // itsGoogleMap.setMyLocationEnabled(true);
    itsGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    itsGoogleMap.setOnMarkerClickListener(this);
    itsGoogleMap.setOnMarkerDragListener(this);
    // itsGoogleMap.setOnMapClickListener(this);
    itsGoogleMap.setOnMapLongClickListener(this);

    itsGoogleMap.clear();
}