java类android.graphics.drawable.ColorDrawable的实例源码

BasicFieldColorViewTest.java 文件源码 项目:Blockly 阅读 43 收藏 0 点赞 0 评论 0
@Test
public void testPopupWindowChangeColor() {
    mFieldColorView.performClick();
    final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow();
    final View popupWindowContentView = popupWindow.getContentView();
    assertThat(popupWindowContentView).isNotNull();

    // Reset color before test.
    mFieldColor.setColor(0);
    assertThat(mFieldColor.getColor()).isEqualTo(0);

    // Simulate click on the color panel.
    popupWindowContentView.onTouchEvent(
            MotionEvent.obtain(0 /* downTime */, 0 /* eventTime */, MotionEvent.ACTION_DOWN,
                    0f /* x */, 0f /* y */, 0 /* metaState */));

    // Verify both field and field view background have been set to correct color.
    final int expectedColour = 0xffffff;
    assertThat(mFieldColor.getColor())
            .isEqualTo(expectedColour);  // setColour() masks out alpha.
    assertThat(((ColorDrawable) mFieldColorView.getBackground()).getColor())
            .isEqualTo(BasicFieldColorView.ALPHA_OPAQUE | expectedColour);

    // Popup window should have disappeared.
    assertThat(popupWindow.isShowing()).isFalse();
}
SingleRequestTest.java 文件源码 项目:GitHub 阅读 39 收藏 0 点赞 0 评论 0
@Test
public void testErrorDrawableIsSetOnLoadFailed() {
  Drawable expected = new ColorDrawable(Color.RED);

  MockTarget target = new MockTarget();

  harness.errorDrawable = expected;
  harness.target = target;
  SingleRequest<List> request = harness.getRequest();

  request.onLoadFailed(new GlideException("test"));

  assertEquals(expected, target.currentPlaceholder);
}
AppNavigationTest.java 文件源码 项目:Espresso 阅读 37 收藏 0 点赞 0 评论 0
/**
 * A customized {@link Matcher} for testing that
 * if one color match the background color of current view.
 * @param backgroundColor A color int value.
 *
 * @return Match or not.
 */
public static Matcher<View> withBackgroundColor(final int backgroundColor) {
    return new TypeSafeMatcher<View>() {

        @Override
        public boolean matchesSafely(View view) {
            int color = ((ColorDrawable) view.getBackground().getCurrent()).getColor();
            return color == backgroundColor;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("with background color value: " + backgroundColor);
        }
    };
}
MenuPopupWindow.java 文件源码 项目:mine-android-repository 阅读 44 收藏 0 点赞 0 评论 0
public MenuPopupWindow(Activity context, OnItemClickListener mListener){
    LayoutInflater inflater = LayoutInflater.from(context);
    view = inflater.inflate(R.layout.layout_popup_menu, null);
    this.mListener = mListener;
    this.setContentView(view);
    this.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    //设置SelectPicPopupWindow弹出窗体的高
    this.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
    //设置SelectPicPopupWindow弹出窗体可点击
    this.setFocusable(false);
    this.setOutsideTouchable(true);
    this.setBackgroundDrawable(new ColorDrawable(0x00000000));

    view.findViewById(R.id.lay_share).setOnClickListener(this);
    view.findViewById(R.id.lay_inform).setOnClickListener(this);
}
MainActivity.java 文件源码 项目:Autocomplete 阅读 48 收藏 0 点赞 0 评论 0
private void setupUserAutocomplete() {
    EditText edit = (EditText) findViewById(R.id.single);
    float elevation = 6f;
    Drawable backgroundDrawable = new ColorDrawable(Color.WHITE);
    AutocompletePresenter<User> presenter = new UserPresenter(this);
    AutocompleteCallback<User> callback = new AutocompleteCallback<User>() {
        @Override
        public boolean onPopupItemClicked(Editable editable, User item) {
            editable.clear();
            editable.append(item.getFullname());
            return true;
        }

        public void onPopupVisibilityChanged(boolean shown) {}
    };

    userAutocomplete = Autocomplete.<User>on(edit)
            .with(elevation)
            .with(backgroundDrawable)
            .with(presenter)
            .with(callback)
            .build();
}
SingleRequestTest.java 文件源码 项目:GitHub 阅读 36 收藏 0 点赞 0 评论 0
@Test
public void testErrorDrawableSetOnNullModelWithErrorDrawable() {
  Drawable placeholder = new ColorDrawable(Color.RED);
  Drawable errorPlaceholder = new ColorDrawable(Color.GREEN);

  MockTarget target = new MockTarget();

  harness.placeholderDrawable = placeholder;
  harness.errorDrawable = errorPlaceholder;
  harness.target = target;
  harness.model = null;
  SingleRequest<List> request = harness.getRequest();

  request.begin();

  assertEquals(errorPlaceholder, target.currentPlaceholder);
}
FilePicker.java 文件源码 项目:MainCalendar 阅读 38 收藏 0 点赞 0 评论 0
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setBackgroundColor(Color.WHITE);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    ListView listView = new ListView(activity);
    listView.setBackgroundColor(Color.WHITE);
    listView.setDivider(new ColorDrawable(0xFFDDDDDD));
    listView.setDividerHeight(1);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setSelector(R.color.itemSelected);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
    rootLayout.addView(listView);
    return rootLayout;
}
CancelListActivity.java 文件源码 项目:MyCalendar 阅读 76 收藏 0 点赞 0 评论 0
private void initView() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
    }
    mCoordinatorLayout = findViewById(R.id.coordinator);

    RecyclerView recyclerView = findViewById(R.id.recycle_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    mAdapter = new CancelAdapter(this, new ArrayList<DayLesson>());
    @SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
    recyclerView.setAdapter(animatorAdapter);

    ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
    ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
    touchHelper.attachToRecyclerView(recyclerView);

    mView_FABMenu = findViewById(R.id.fab_menu_1);
    mView_FABMenu.setVisibility(View.GONE);
}
SettingsActivity.java 文件源码 项目:simple-share-android 阅读 34 收藏 0 点赞 0 评论 0
public void changeActionBarColor(int newColor) {

        int color = newColor != 0 ? newColor : SettingsActivity.getPrimaryColor(this);
        Drawable colorDrawable = new ColorDrawable(color);

        if (oldBackground == null) {
            getSupportActionBar().setBackgroundDrawable(colorDrawable);

        } else {
            TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
            getSupportActionBar().setBackgroundDrawable(td);
            td.startTransition(200);
        }

        oldBackground = colorDrawable;
    }
TintManager.java 文件源码 项目:Mix 阅读 43 收藏 0 点赞 0 评论 0
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) {
    if (view == null || drawable == null) return;
    if (tint.mHasTintList || tint.mHasTintMode) {
        drawable.mutate();
        if (drawable instanceof ColorDrawable) {
            ((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor())));
        } else {
            drawable.setColorFilter(createTintFilter(view.getContext(),
                    tint.mHasTintList ? tint.mTintList : null,
                    tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE,
                    view.getDrawableState()));
        }
    } else {
        drawable.clearColorFilter();
    }

    if (Build.VERSION.SDK_INT <= 23) {
        // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter
        // has changed, so we need to force an invalidation
        drawable.invalidateSelf();
    }
}
StyledDialogFragment.java 文件源码 项目:android_nextgis_mobile 阅读 39 收藏 0 点赞 0 评论 0
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}
GuiUtils.java 文件源码 项目:MobileAppForPatient 阅读 34 收藏 0 点赞 0 评论 0
public static Dialog showConfirmDialog(Activity activity, boolean cancelable, String title, String message,
           final CustomAlertOnClickListener backHandler) {

       Dialog dialog = new Dialog(activity, R.style.CustomDialog);
       dialog.setContentView(R.layout.confirm_dialog);
       dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
       dialog.setCancelable(cancelable);

       TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_title);
       TextView tvContent = (TextView) dialog.findViewById(R.id.tv_content);
       Button btnBack = (Button) dialog.findViewById(R.id.btn_confirm);

       if (!TextUtils.isEmpty(title)) {
           tvTitle.setText(title);
       }
       tvContent.setText(message);

       dialog.show();

       final Dialog inDialog = dialog;
       btnBack.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               if (backHandler != null) {
                   backHandler.onClick(inDialog, v);
               }
           }
       });

       return dialog;
}
ActionSheet.java 文件源码 项目:quickhybrid-android 阅读 36 收藏 0 点赞 0 评论 0
public Attributes(Context context) {
    mContext = context;
    this.background = new ColorDrawable(Color.TRANSPARENT);
    this.cancelButtonBackground = new ColorDrawable(Color.BLACK);
    ColorDrawable gray = new ColorDrawable(Color.GRAY);
    this.otherButtonTopBackground = gray;
    this.otherButtonMiddleBackground = gray;
    this.otherButtonBottomBackground = gray;
    this.otherButtonSingleBackground = gray;
    this.cancelButtonTextColor = Color.WHITE;
    this.otherButtonTextColor = Color.BLACK;
    this.padding = dp2px(20);
    this.otherButtonSpacing = dp2px(2);
    this.cancelButtonMarginTop = dp2px(10);
    this.actionSheetTextSize = dp2px(16);
}
ChromeActivity.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 42 收藏 0 点赞 0 评论 0
@Override
public void finishNativeInitialization() {
    // The window background color is used as the resizing background color in Android N+
    // multi-window mode. See crbug.com/602366.
    if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        getWindow().setBackgroundDrawable(new ColorDrawable(
                ApiCompatibilityUtils.getColor(getResources(),
                        R.color.resizing_background_color)));
    } else {
        removeWindowBackground();
    }
    DownloadManagerService.getDownloadManagerService(
            getApplicationContext()).onActivityLaunched();

    super.finishNativeInitialization();
}
ImageFolderPopupWindow.java 文件源码 项目:OSchina_resources_android 阅读 35 收藏 0 点赞 0 评论 0
@SuppressLint("InflateParams")
 ImageFolderPopupWindow(Context context, Callback callback) {
    super(LayoutInflater.from(context).inflate(R.layout.popup_window_folder, null),
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    mCallback = callback;

    // init
    setAnimationStyle(R.style.popup_anim_style_alpha);
    setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    setOutsideTouchable(true);
    setFocusable(true);

    // content
    View content = getContentView();
    content.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    content.addOnAttachStateChangeListener(this);

    mFolderView = (RecyclerView) content.findViewById(R.id.rv_popup_folder);
    mFolderView.setLayoutManager(new LinearLayoutManager(context));

}
BaseDialog.java 文件源码 项目:EosCommander 阅读 45 收藏 0 点赞 0 评论 0
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // the content
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getContext());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    if (dialog.getWindow() != null) {
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.getWindow().setLayout(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}
BaseDialog.java 文件源码 项目:GitHub 阅读 43 收藏 0 点赞 0 评论 0
private void initDialog() {
    contentLayout = new FrameLayout(activity);
    contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    contentLayout.setFocusable(true);
    contentLayout.setFocusableInTouchMode(true);
    //contentLayout.setFitsSystemWindows(true);
    dialog = new Dialog(activity);
    dialog.setCanceledOnTouchOutside(false);//触摸屏幕取消窗体
    dialog.setCancelable(false);//按返回键取消窗体
    dialog.setOnKeyListener(this);
    dialog.setOnDismissListener(this);
    Window window = dialog.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //AndroidRuntimeException: requestFeature() must be called before adding content
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(contentLayout);
    }
    setSize(screenWidthPixels, WRAP_CONTENT);
}
PowerMenuUtils.java 文件源码 项目:PowerMenu 阅读 39 收藏 0 点赞 0 评论 0
public static CustomPowerMenu getWritePowerMenu(Context context, LifecycleOwner lifecycleOwner, OnMenuItemClickListener onMenuItemClickListener) {
    ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(R.color.md_blue_grey_300));
    return new CustomPowerMenu.Builder<>(context, new CenterMenuAdapter())
            .addItem("Novel")
            .addItem("Poetry")
            .addItem("Art")
            .addItem("Journals")
            .addItem("Travel")
            .setLifecycleOwner(lifecycleOwner)
            .setAnimation(MenuAnimation.FADE)
            .setMenuRadius(10f)
            .setMenuShadow(10f)
            .setDivider(drawable)
            .setDividerHeight(1)
            .setOnMenuItemClickListener(onMenuItemClickListener)
            .build();
}
BrowserByShow.java 文件源码 项目:aos-Video 阅读 37 收藏 0 点赞 0 评论 0
@Override
protected void setColor(int color) {

    int darkColor = VideoInfoCommonClass.getDarkerColor(color);
    ColorDrawable[] colord = {new ColorDrawable(mLastColor), new ColorDrawable(darkColor)};
    TransitionDrawable trans = new TransitionDrawable(colord);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        mApplicationFrameLayout.setBackground(trans);
    else
        mApplicationFrameLayout.setBackgroundDrawable(trans);
    trans.startTransition(200);
    mLastColor = darkColor;
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getActivity().getWindow().setStatusBarColor(VideoInfoCommonClass.getAlphaColor(darkColor, 160));
    }

}
DrawableTransformationTest.java 文件源码 项目:GitHub 阅读 36 收藏 0 点赞 0 评论 0
@Test
public void load_withColorDrawable_fixedSize_functionalBitmapTransform_doesNotRecycleOutput()
    throws ExecutionException, InterruptedException {
  Drawable colorDrawable = new ColorDrawable(Color.RED);

  int width = 100;
  int height = 200;

  Drawable result = GlideApp.with(context)
      .load(colorDrawable)
      .circleCrop()
      .override(width, height)
      .submit()
      .get();

   BitmapSubject.assertThat(result).isNotRecycled();

  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  // Make sure we didn't put the same Bitmap twice.
  Bitmap first = bitmapPool.get(width, height, Config.ARGB_8888);
  Bitmap second = bitmapPool.get(width, height, Config.ARGB_8888);

  assertThat(first).isNotSameAs(second);
}
BaseDialog.java 文件源码 项目:TheNounProject 阅读 55 收藏 0 点赞 0 评论 0
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getContext());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    if (dialog.getWindow() != null) {
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.getWindow().setLayout(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
Coloring.java 文件源码 项目:silly-android 阅读 49 收藏 0 点赞 0 评论 0
/**
 * Creates a new drawable (implementation of the Drawable object may vary depending on the OS version).
 * The result Drawable will be colored with the given color, and clipped to match the given bounds.
 * Note that the drawable's alpha is set to 0 when argument color is {@link Color#TRANSPARENT}.
 *
 * @param color  Integer color used to color the output drawable
 * @param bounds Four-dimensional vector representing drawable bounds
 * @return Colored and clipped drawable object
 */
@NonNull
public static Drawable createColoredDrawable(@ColorInt final int color, @Nullable final Rect bounds) {
    // create the drawable depending on the OS (pre-Honeycomb couldn't use color drawables inside state lists)
    Drawable drawable;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || bounds != null) {
        drawable = new GradientDrawable(Orientation.BOTTOM_TOP, new int[] { color, color }).mutate();
    } else {
        drawable = new ColorDrawable(color).mutate();
    }

    // set the alpha value
    if (color == Color.TRANSPARENT) {
        drawable.setAlpha(0);
    }

    // update bounds
    if (bounds != null) {
        drawable.setBounds(bounds);
    }
    return drawable;
}
EntityHeaderController.java 文件源码 项目:MiPushFramework 阅读 42 收藏 0 点赞 0 评论 0
public EntityHeaderController styleActionBar(AppCompatActivity activity) {
    if (activity == null) {
        Log.w(TAG, "No activity, cannot style actionbar.");
        return this;
    }
    final ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar == null) {
        Log.w(TAG, "No actionbar, cannot style actionbar.");
        return this;
    }
    actionBar.setBackgroundDrawable(
            new ColorDrawable(Utils.getColorAttr(activity, R.attr.colorSettings)));
    actionBar.setElevation(0);
    //if (mRecyclerView != null && mLifecycle != null) {
    //    ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
    //}

    return this;
}
PicViewerPage.java 文件源码 项目:Mobike 阅读 28 收藏 0 点赞 0 评论 0
public void onCreate() {
    activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));

    sivViewer = new ScaledImageView(activity);
    sivViewer.setScaleType(ScaleType.MATRIX);
    activity.setContentView(sivViewer);
    if (pic != null) {
        sivViewer.getViewTreeObserver().addOnGlobalLayoutListener(this);
    }
}
GraphListView.java 文件源码 项目:buildAPKsApps 阅读 38 收藏 0 点赞 0 评论 0
public GraphListView(Context ctx) {
  super(ctx);
  setCacheColorHint(0xFFFFFFFF);
  setBackgroundColor(0xFFFFFFFF);
  setDivider(new ColorDrawable(0xFF898989));
  setDividerHeight(1);
  db_ = SeismoDbAdapter.getAdapter();
  db_.open(ctx);
  graph_names_ = db_.fetchGraphNames();
  adapter_ = new ArrayAdapter<String>(ctx, R.layout.export, graph_names_);
  setAdapter(adapter_);
  db_.close();
}
SettingsDialog.java 文件源码 项目:AdaptiveTableLayout 阅读 40 收藏 0 点赞 0 评论 0
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    //noinspection ConstantConditions
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    View view = inflater.inflate(R.layout.dialog_settings, container, false);
    swSolidRow = (SwitchCompat) view.findViewById(R.id.swSolidRow);
    swFixedHeaders = (SwitchCompat) view.findViewById(R.id.swFixedHeaders);
    swRtlDirection = (SwitchCompat) view.findViewById(R.id.swRtlDirection);
    swDragAndDropEnabled = (SwitchCompat) view.findViewById(R.id.swDragAndDropEnabled);

    return view;
}
ContactDetailActivity.java 文件源码 项目:sealtalk-android-master 阅读 47 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.rc_ac_contact_detail);
    getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    initView();
    initData();
}
BucketAdapter.java 文件源码 项目:Watermark 阅读 38 收藏 0 点赞 0 评论 0
public BucketAdapter(
        List<BucketBean> bucketList,
        Configuration configuration,
        @ColorInt int color) {
    this.mBucketList = bucketList;
    this.mConfiguration = configuration;
    this.mDefaultImage = new ColorDrawable(color);
}
CircleImageView.java 文件源码 项目:Logistics-guard 阅读 39 收藏 0 点赞 0 评论 0
private Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    try {
        Bitmap bitmap;

        if (drawable instanceof ColorDrawable) {
            bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
        } else {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
        }

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
OneDrawable.java 文件源码 项目:OneDrawable 阅读 45 收藏 0 点赞 0 评论 0
private static Drawable getUnableStateDrawable(Context context, @NonNull Drawable unable) {
    if (isKitkat() && !(unable instanceof ColorDrawable)) {
        return kitkatUnableDrawable(context, unable);
    }
    unable.setAlpha(convertAlphaToInt(0.5f));
    return unable;
}


问题


面经


文章

微信
公众号

扫码关注公众号