List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:com.ibm.mil.readyapps.physio.fragments.PainManagementFragment.java
private void setupView(View view) { // set custom fonts TextView painQuestion = (TextView) view.findViewById(R.id.pain_question); painQuestion.setTypeface(AndroidUtils.robotoRegular(view.getContext())); TextView painDescription = (TextView) view.findViewById(R.id.pain_description); painDescription.setTypeface(AndroidUtils.robotoBold(view.getContext())); mEnterPainDescription = (EditText) view.findViewById(R.id.enter_pain_description); mEnterPainDescription.setTypeface(AndroidUtils.robotoRegular(view.getContext())); Button submitButton = (Button) view.findViewById(R.id.pain_submit_button); submitButton.setTypeface(AndroidUtils.robotoRegular(view.getContext())); final TextView painCircleNumber = (TextView) view.findViewById(R.id.pain_circle_number); painCircleNumber.setTypeface(AndroidUtils.robotoBold(view.getContext())); // initialize pain picker int minScaleValue = 0; int maxScaleValue = 10; TextView minLabel = (TextView) view.findViewById(R.id.min_label); minLabel.setTypeface(AndroidUtils.robotoThin(view.getContext())); TextView maxLabel = (TextView) view.findViewById(R.id.max_label); maxLabel.setTypeface(AndroidUtils.robotoThin(view.getContext())); TextView minValue = (TextView) view.findViewById(R.id.min_value); minValue.setTypeface(AndroidUtils.robotoBold(view.getContext())); minValue.setText(Integer.toString(minScaleValue)); TextView maxValue = (TextView) view.findViewById(R.id.max_value); maxValue.setTypeface(AndroidUtils.robotoBold(view.getContext())); maxValue.setText(Integer.toString(maxScaleValue)); mPainPicker = (WheelHorizontalView) view.findViewById(R.id.pain_picker); NumericWheelAdapter painAdapter = new NumericWheelAdapter(view.getContext(), minScaleValue, maxScaleValue); painAdapter.setItemResource(R.layout.pain_picker_text); painAdapter.setItemTextResource(R.id.pain_text); painAdapter.setTextTypeface(AndroidUtils.robotoRegular(view.getContext())); mPainPicker.setViewAdapter(painAdapter); mPainPicker.setVisibleItems(maxScaleValue - minScaleValue); mPainPicker.setItemsDimmedAlpha(255); int defaultScore = (maxScaleValue - minScaleValue) / 2; mPainPicker.setCurrentItem(defaultScore); painCircleNumber.setText(Integer.toString(mPainPicker.getCurrentItem())); // update pain circle number with the current centered value mPainPicker.addChangingListener(new OnWheelChangedListener() { @Override// w ww . j a v a2 s . c om public void onChanged(AbstractWheel wheel, int oldValue, int newValue) { painCircleNumber.setText(Integer.toString(newValue)); } }); submitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final PhysioAlertDialog alertDialog = new PhysioAlertDialog(getActivity()); String message; if (isFormLayout) { message = getResources().getString(R.string.form_confirm); } else { message = getResources().getString(R.string.pain_confirm); } alertDialog.setPrimaryText(message); alertDialog.hideSecondaryText(true); if (!isFormLayout) { ColorDrawable color = new ColorDrawable(getResources().getColor(R.color.ready_red)); alertDialog.setButtonDrawable(color); } alertDialog.setPositiveClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Realm realm = Realm.getInstance(getActivity()); realm.beginTransaction(); PainReport report = realm.createObject(PainReport.class); report.setDate(new Date()); report.setPainAmount(mPainPicker.getCurrentItem()); report.setDescription(mEnterPainDescription.getText().toString()); realm.commitTransaction(); // force refresh in ProgressFragment to show new pain report data ProgressFragment.clearData(); final PhysioDialog dialog = new PhysioDialog(getActivity()); String message; if (isFormLayout) { message = getResources().getString(R.string.form_confirmed); } else { message = getResources().getString(R.string.pain_confirmed); dialog.getIcon().setImageDrawable(getResources().getDrawable(R.drawable.checkmark_red)); } dialog.getPrimaryMessage().setText(message); dialog.getSecondaryMessage().setVisibility(View.GONE); dialog.getButton().setVisibility(View.GONE); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { showLandingScreen(); } }); dialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showLandingScreen(); dialog.cancel(); } }); dialog.show(); alertDialog.dismiss(); } }); alertDialog.setNegativeClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); } }); alertDialog.show(); } }); }
From source file:com.armtimes.activities.SingleArticlePreviewActivity.java
private void initActionBarTitle(final Intent intent, final ActionBar actionBar) { int title = R.string.app_name; try {/* w w w . j a v a2s. co m*/ title = intent.getIntExtra(EXTRA_CATEGORY_TITLE_ID, 0); } finally { actionBar.setTitle(Html.fromHtml("<small>" + getResources().getString(title) + "</small>")); actionBar.setBackgroundDrawable(new ColorDrawable(0xFFFA294C)); } }
From source file:com.drjane.promise.ui.fragment.CalendarFragment.java
private void initGridView() { // ??//from w w w . j av a 2s . com WindowManager windowManager = getActivity().getWindowManager(); Display display = windowManager.getDefaultDisplay(); int Width = display.getWidth(); int Height = display.getHeight(); mGridView = new CustomGridView(getActivity()); mGridView.setNumColumns(7); mGridView.setColumnWidth(40); // gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); if (Width == 720 && Height == 1280) { mGridView.setColumnWidth(40); } mGridView.setGravity(Gravity.CENTER_VERTICAL); mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); // gridView mGridView.setVerticalSpacing(1); mGridView.setHorizontalSpacing(1); mHandler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub mGridView.setAdapter(calendarGridViewAdapter); } }); }
From source file:com.goforer.base.ui.helper.RecyclerItemTouchHelperCallback.java
private void init() { mBackground = new ColorDrawable(mBgColor); mDeleteIcon = ContextCompat.getDrawable(mContext, R.drawable.ic_delete_item); mDeleteIconMargin = (int) mContext.getResources().getDimension(R.dimen.helper_icon_clear_margin); mInitiated = true;//from w ww .jav a 2 s.c om }
From source file:com.jose.castsocialconnector.main.MainActivity.java
private void setActionBarStyle() { ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00B2A6"))); this.getSupportActionBar().setDisplayShowCustomEnabled(true); this.getSupportActionBar().setDisplayShowTitleEnabled(false); LayoutInflater inflator = LayoutInflater.from(this); View v = inflator.inflate(R.layout.action_bar, null); ((TextView) v.findViewById(R.id.title)).setText(this.getTitle()); ((TextView) v.findViewById(R.id.title)).setTypeface(typeFaceBold); ((TextView) v.findViewById(R.id.title)).setTextColor(Color.parseColor("#FFFFFF")); this.getSupportActionBar().setCustomView(v); }
From source file:com.amaze.filemanager.fragments.ProcessViewerFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setRetainInstance(true);//from w w w . j av a 2 s . co m mainActivity.getAppbar().setTitle(R.string.process_viewer); mainActivity.floatingActionButton.getMenuButton().hide(); mainActivity.getAppbar().getBottomBar().setVisibility(View.GONE); mainActivity.supportInvalidateOptionsMenu(); int skin_color = mainActivity.getCurrentColorPreference().primaryFirstTab; int skinTwoColor = mainActivity.getCurrentColorPreference().primarySecondTab; accentColor = mainActivity.getAccent(); mainActivity.updateViews(new ColorDrawable(MainActivity.currentTab == 1 ? skinTwoColor : skin_color)); }
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
private static Drawable createButtonNormalBg(Context context, int colorControlHighlight) { StateListDrawable sld = new StateListDrawable(); sld.addState(new int[] { android.R.attr.state_pressed }, createButtonShape(context, colorControlHighlight)); sld.addState(new int[] {}, new ColorDrawable(Color.TRANSPARENT)); return sld;/* www .j a va 2 s .co m*/ }
From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); LinearLayout layout = new LinearLayout(mParentActivity); layout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); mTextViewTitle = new TextView(mParentActivity); LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10); mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); layout.addView(mTextViewTitle, textviewParams); mInputEditText = new EditText(mParentActivity); LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10); layout.addView(mInputEditText, editTextParams); setContentView(layout, layoutParams); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); mInputMode = mMsg.inputMode;/*from ww w . j ava 2 s .co m*/ mInputFlag = mMsg.inputFlag; mReturnType = mMsg.returnType; mMaxLength = mMsg.maxLength; mTextViewTitle.setText(mMsg.title); mInputEditText.setText(mMsg.content); int oldImeOptions = mInputEditText.getImeOptions(); mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); oldImeOptions = mInputEditText.getImeOptions(); switch (mInputMode) { case kEditBoxInputModeAny: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE; break; case kEditBoxInputModeEmailAddr: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case kEditBoxInputModeNumeric: mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModePhoneNumber: mInputModeContraints = InputType.TYPE_CLASS_PHONE; break; case kEditBoxInputModeUrl: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; break; case kEditBoxInputModeDecimal: mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModeSingleLine: mInputModeContraints = InputType.TYPE_CLASS_TEXT; break; default: break; } if (mIsMultiline) { mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; } mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints); switch (mInputFlag) { case kEditBoxInputFlagPassword: mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; break; case kEditBoxInputFlagSensitive: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; break; case kEditBoxInputFlagInitialCapsWord: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; break; case kEditBoxInputFlagInitialCapsSentence: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; break; case kEditBoxInputFlagInitialCapsAllCharacters: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; break; default: break; } mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints); switch (mReturnType) { case kKeyboardReturnTypeDefault: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; case kKeyboardReturnTypeDone: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); break; case kKeyboardReturnTypeSend: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); break; case kKeyboardReturnTypeSearch: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); break; case kKeyboardReturnTypeGo: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); break; default: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; } if (mMaxLength > 0) { mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) }); } Handler initHandler = new Handler(); initHandler.postDelayed(new Runnable() { public void run() { mInputEditText.requestFocus(); mInputEditText.setSelection(mInputEditText.length()); openKeyboard(); } }, 200); mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // if user didn't set keyboard type, // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP' if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null && event.getAction() == KeyEvent.ACTION_DOWN)) { //Log.d("EditBox", "actionId: "+actionId +",event: "+event); mParentActivity.setEditBoxResult(mInputEditText.getText().toString()); closeKeyboard(); dismiss(); return true; } return false; } }); }
From source file:com.hufeiya.SignIn.fragment.CategorySelectionFragment.java
private void setStudentDrawer(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/*from w ww .j av a2s.co m*/ public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) { return false; } }).build(); PrimaryDrawerItem index = new PrimaryDrawerItem().withName(""); SecondaryDrawerItem mySignItem = new SecondaryDrawerItem().withName(""); //create the drawer and remember the `Drawer` result object drawer = new DrawerBuilder().withAccountHeader(headerResult).withActivity(getActivity()) .addDrawerItems(index, new DividerDrawerItem(), mySignItem) .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.hitomi.circlemenu.transtion.FabTransform.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues, final TransitionValues endValues) { if (startValues == null || endValues == null) return null; final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS); final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS); final boolean fromFab = endBounds.width() > startBounds.width(); final View view = endValues.view; final Rect dialogBounds = fromFab ? endBounds : startBounds; final Rect fabBounds = fromFab ? startBounds : endBounds; final Interpolator fastOutSlowInInterpolator = AnimUtils .getFastOutSlowInInterpolator(sceneRoot.getContext()); final long duration = getDuration(); final long halfDuration = duration / 2; final long twoThirdsDuration = duration * 2 / 3; if (!fromFab) { // Force measure / layout the dialog back to it'page_two original bounds view.measure(makeMeasureSpec(startBounds.width(), View.MeasureSpec.EXACTLY), makeMeasureSpec(startBounds.height(), View.MeasureSpec.EXACTLY)); view.layout(startBounds.left, startBounds.top, startBounds.right, startBounds.bottom); }//from w w w .j a v a2 s. c om final int translationX = startBounds.centerX() - endBounds.centerX(); final int translationY = startBounds.centerY() - endBounds.centerY(); if (fromFab) { view.setTranslationX(translationX); view.setTranslationY(translationY); } // Add a color overlay to fake appearance of the FAB final ColorDrawable fabColor = new ColorDrawable(color); fabColor.setBounds(0, 0, dialogBounds.width(), dialogBounds.height()); if (!fromFab) fabColor.setAlpha(0); view.getOverlay().add(fabColor); // Add an icon overlay again to fake the appearance of the FAB final Drawable fabIcon = ContextCompat.getDrawable(sceneRoot.getContext(), icon).mutate(); final int iconLeft = (dialogBounds.width() - fabIcon.getIntrinsicWidth()) / 2; final int iconTop = (dialogBounds.height() - fabIcon.getIntrinsicHeight()) / 2; fabIcon.setBounds(iconLeft, iconTop, iconLeft + fabIcon.getIntrinsicWidth(), iconTop + fabIcon.getIntrinsicHeight()); if (!fromFab) fabIcon.setAlpha(0); view.getOverlay().add(fabIcon); // Circular clip from/to the FAB size final Animator circularReveal; if (fromFab) { circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, startBounds.width() / 2, (float) Math.hypot(endBounds.width() / 2, endBounds.height() / 2)); circularReveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(sceneRoot.getContext())); } else { circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, (float) Math.hypot(startBounds.width() / 2, startBounds.height() / 2), endBounds.width() / 2); circularReveal.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(sceneRoot.getContext())); // Persist the end clip i.e. stay at FAB size after the reveal has run circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { final int left = (view.getWidth() - fabBounds.width()) / 2; final int top = (view.getHeight() - fabBounds.height()) / 2; outline.setOval(left, top, left + fabBounds.width(), top + fabBounds.height()); view.setClipToOutline(true); } }); } }); } circularReveal.setDuration(duration); // Translate to end position along an arc final Animator translate = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, View.TRANSLATION_Y, fromFab ? getPathMotion().getPath(translationX, translationY, 0, 0) : getPathMotion().getPath(0, 0, -translationX, -translationY)); translate.setDuration(duration); translate.setInterpolator(fastOutSlowInInterpolator); // Fade contents of non-FAB view in/out List<Animator> fadeContents = null; if (view instanceof ViewGroup) { final ViewGroup vg = ((ViewGroup) view); fadeContents = new ArrayList<>(vg.getChildCount()); for (int i = vg.getChildCount() - 1; i >= 0; i--) { final View child = vg.getChildAt(i); final Animator fade = ObjectAnimator.ofFloat(child, View.ALPHA, fromFab ? 1f : 0f); if (fromFab) { child.setAlpha(0f); } fade.setDuration(twoThirdsDuration); fade.setInterpolator(fastOutSlowInInterpolator); fadeContents.add(fade); } } // Fade in/out the fab color & icon overlays final Animator colorFade = ObjectAnimator.ofInt(fabColor, "alpha", fromFab ? 0 : 255); final Animator iconFade = ObjectAnimator.ofInt(fabIcon, "alpha", fromFab ? 0 : 255); if (!fromFab) { colorFade.setStartDelay(halfDuration); iconFade.setStartDelay(halfDuration); } colorFade.setDuration(halfDuration); iconFade.setDuration(halfDuration); colorFade.setInterpolator(fastOutSlowInInterpolator); iconFade.setInterpolator(fastOutSlowInInterpolator); // Work around issue with elevation shadows. At the end of the return transition the shared // element'page_two shadow is drawn twice (by each activity) which is jarring. This workaround // still causes the shadow to snap, but it'page_two better than seeing it double drawn. Animator elevation = null; if (!fromFab) { elevation = ObjectAnimator.ofFloat(view, View.TRANSLATION_Z, -view.getElevation()); elevation.setDuration(duration); elevation.setInterpolator(fastOutSlowInInterpolator); } // Run all animations together final AnimatorSet transition = new AnimatorSet(); transition.playTogether(circularReveal, translate, colorFade, iconFade); transition.playTogether(fadeContents); if (elevation != null) transition.play(elevation); if (fromFab) { transition.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Clean up view.getOverlay().clear(); } }); } return new AnimUtils.NoPauseAnimator(transition); }