Java Code Examples for android.graphics.drawable.ColorDrawable.setAlpha()

The following are Jave code examples for showing how to use setAlpha() of the android.graphics.drawable.ColorDrawable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Musicoco   File: HomeBackgroundController.java   Source Code and License Vote up 6 votes
private void setImageBitmap(Bitmap bitmap) {
    if (bitmap != null) {

        // menu 中有图标时要通过 getHeaderView 查找子 view
        View headerView = navigationView.getHeaderView(0);
        ImageView iv = (ImageView) headerView.findViewById(R.id.main_left_nav_image);
        iv.setImageBitmap(bitmap);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            ColorDrawable cd = new ColorDrawable(Color.BLACK);
            int alpha = appPreference.getImageWallAlpha();
            cd.setAlpha(alpha);
            iv.setForeground(cd);
        }

        Animation animation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_in);
        iv.startAnimation(animation);
    }

}
 
Example 2
Project: memento-app   File: SlidingSearchViewExampleFragment.java   Source Code and License Vote up 6 votes
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mSearchView = (FloatingSearchView) view.findViewById(R.id.floating_search_view);
    mHeaderView = (TextView)view.findViewById(R.id.header_view);

    mSearchResultsList = (RecyclerView) view.findViewById(R.id.search_results_list);

    mDimSearchViewBackground = view.findViewById(R.id.dim_background);
    mDimDrawable = new ColorDrawable(Color.BLACK);
    mDimDrawable.setAlpha(0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mDimSearchViewBackground.setBackground(mDimDrawable);
    }else {
        mDimSearchViewBackground.setBackgroundDrawable(mDimDrawable);
    }
    smar_group_id = checkSmarGroup();
    isFocus = false;
    setupFloatingSearch();
    setupResultsList();
    setupDrawer();
    Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/league.ttf");
    mHeaderView.setTypeface(font);
}
 
Example 3
Project: Musicoco   File: BottomNavigationController.java   Source Code and License Vote up 5 votes
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {

    int[] cs = ColorUtils.get10ThemeColors(activity, themeEnum);

    int statusC = cs[0];
    int toolbarC = cs[1];
    int accentC = cs[2];
    int mainBC = cs[3];
    int vicBC = cs[4];
    int mainTC = cs[5];
    int vicTC = cs[6];
    int navC = cs[7];
    int toolbarMainTC = cs[8];
    int toolbarVicTC = cs[9];

    listViewsController.themeChange(themeEnum, cs);

    mContainer.setBackgroundColor(navC);
    mName.setTextColor(mainTC);
    mArts.setTextColor(vicTC);

    mPlay.setPauseLineColor(mainTC);
    mPlay.setSolidColor(mainTC);
    mPlay.setTriangleColor(mainTC);

    mProgress.setBackgroundColor(accentC);

    ColorDrawable cd = new ColorDrawable(vicBC);
    cd.setAlpha(200);
    mProgressBG.setBackground(cd);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mShowList.getDrawable().setTint(mainTC);
    }
}
 
Example 4
Project: Musicoco   File: DialogUtils.java   Source Code and License Vote up 5 votes
public static void showDetailDialog(Activity activity, SongInfo info) {
    DialogProvider manager = new DialogProvider(activity);

    String[] infos = new String[7];
    infos[0] = "歌曲:" + info.getTitle();
    infos[1] = "歌手:" + info.getArtist();
    infos[2] = "专辑:" + info.getAlbum();
    infos[3] = "时长:" + StringUtils.getGenTimeMS((int) info.getDuration());
    infos[4] = "格式:" + info.getMime_type();
    infos[5] = "大小:" + String.valueOf(info.getSize() >> 10 >> 10) + " MB";
    infos[6] = "路径:" + info.getData();

    View view = activity.getLayoutInflater().inflate(R.layout.list_image, null);
    ListView listView = (ListView) view.findViewById(R.id.list_image_list);
    ImageView imageView = (ImageView) view.findViewById(R.id.list_image_image);
    listView.setAdapter(new ArrayAdapter<String>(
            activity,
            R.layout.text_view_start,
            infos
    ));

    Bitmap b = BitmapUtils.bitmapResizeFromFile(
            info.getAlbum_path(),
            imageView.getWidth(),
            imageView.getHeight());
    if (b == null) {
        b = BitmapUtils.getDefaultPictureForAlbum(activity, imageView.getWidth(), imageView.getHeight());
    }

    if (b != null) {
        imageView.setImageBitmap(b);
    }

    ColorDrawable drawable = new ColorDrawable(Color.WHITE);
    drawable.setAlpha(245);
    listView.setBackground(drawable);

    manager.createFullyCustomDialog(view, "歌曲信息").show();
}
 
Example 5
Project: AndroidBasicLibs   File: DrawerToast.java   Source Code and License Vote up 5 votes
/**
 * 重置背景和文字颜色
 */
public void resetDefaultBackgroundAndTextColor() {
    defaultTextColor = Color.WHITE;
    defaultBackgroundColor = new ColorDrawable(Color.BLACK);
    defaultBackgroundColor.setAlpha(200);
    defaultBackgroundResid = null;
}
 
Example 6
Project: MakiLite   File: SlideFinishLayout.java   Source Code and License Vote up 4 votes
public SlideFinishLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mEdgeSlop = ViewConfiguration.get(context).getScaledEdgeSlop();

    mScroller = new Scroller(context);

    if (context instanceof Activity) {
        window = ((Activity) context).getWindow();
        
        backDrawable = new ColorDrawable(getResources().getColor(R.color.black));
        backDrawable.setAlpha((int) (255 * 0.4));
        window.setBackgroundDrawable(backDrawable);
    }

  
    this.setBackgroundResource(R.color.white);
}
 
Example 7
Project: Musicoco   File: BottomNavigationController.java   Source Code and License Vote up 4 votes
public void updateColors(int color, boolean isVarying) {

        ColorDrawable bd = new ColorDrawable(color);
        bd.setAlpha(100);
        mListTitleContainer.setBackground(bd);

        int colorA = ColorUtils.setAlphaComponent(color, 235);
        mViewRoot.setCardBackgroundColor(colorA);

        ThemeEnum t;
        if (com.duan.musicoco.util.ColorUtils.isBrightSeriesColor(colorA)) {
            t = WHITE;
        } else {
            t = DARK;
        }

        int cs[];
        switch (t) {
            case WHITE: {
                if (isVarying) {
                    cs = com.duan.musicoco.util.ColorUtils.get2ColorWhiteThemeForPlayOptions(activity);
                } else {
                    cs = com.duan.musicoco.util.ColorUtils.get2WhiteThemeTextColor(activity);
                }
                break;
            }
            case DARK:
            default: {
                if (isVarying) {
                    cs = com.duan.musicoco.util.ColorUtils.get2ColorDarkThemeForPlayOptions(activity);
                } else {
                    cs = com.duan.musicoco.util.ColorUtils.get2DarkThemeTextColor(activity);
                }
                break;
            }
        }
        songOption.setDrawableColor(cs[0]);
        listOption.setDrawableColor(cs[0]);

        if (playListAdapter != null) {
            playListAdapter.setMainTextColor(cs[0]);
            playListAdapter.setVicTextColor(cs[1]);
        }

        listOption.updateColors();
        songOption.updateColors();

    }
 
Example 8
Project: AndroidBasicLibs   File: DrawerToast.java   Source Code and License Vote up 2 votes
/**
 * 设置默认背景颜色
 *
 * @param color 颜色值
 * @param alpha 透明度
 */
public void setDefaultBackgroundColor(int color, Integer alpha) {
    defaultBackgroundColor = new ColorDrawable(color);
    if (alpha != null) defaultBackgroundColor.setAlpha(alpha);
    defaultBackgroundResid = null;
}