当前位置: 首页>>代码示例>>Java>>正文


Java ColorDrawable类代码示例

本文整理汇总了Java中android.graphics.drawable.ColorDrawable的典型用法代码示例。如果您正苦于以下问题:Java ColorDrawable类的具体用法?Java ColorDrawable怎么用?Java ColorDrawable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColorDrawable类属于android.graphics.drawable包,在下文中一共展示了ColorDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPopupWindowChangeColor

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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();
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:27,代码来源:BasicFieldColorViewTest.java

示例2: testErrorDrawableIsSetOnLoadFailed

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:SingleRequestTest.java

示例3: withBackgroundColor

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
/**
 * 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);
        }
    };
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:23,代码来源:AppNavigationTest.java

示例4: MenuPopupWindow

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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);
}
 
开发者ID:xiaoxiaoqingyi,项目名称:mine-android-repository,代码行数:17,代码来源:MenuPopupWindow.java

示例5: setupUserAutocomplete

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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();
}
 
开发者ID:natario1,项目名称:Autocomplete,代码行数:24,代码来源:MainActivity.java

示例6: testErrorDrawableSetOnNullModelWithErrorDrawable

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:SingleRequestTest.java

示例7: makeCenterView

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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;
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:21,代码来源:FilePicker.java

示例8: initView

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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);
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:26,代码来源:CancelListActivity.java

示例9: changeActionBarColor

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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;
	}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:17,代码来源:SettingsActivity.java

示例10: tintViewDrawable

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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();
    }
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:23,代码来源:TintManager.java

示例11: onCreateDialog

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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;
}
 
开发者ID:nextgis,项目名称:android_nextgis_mobile,代码行数:19,代码来源:StyledDialogFragment.java

示例12: showConfirmDialog

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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;
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:32,代码来源:GuiUtils.java

示例13: Attributes

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
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);
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:17,代码来源:ActionSheet.java

示例14: finishNativeInitialization

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:ChromeActivity.java

示例15: ImageFolderPopupWindow

import android.graphics.drawable.ColorDrawable; //导入依赖的package包/类
@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));

}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:28,代码来源:ImageFolderPopupWindow.java


注:本文中的android.graphics.drawable.ColorDrawable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。