List of usage examples for android.graphics.drawable ShapeDrawable ShapeDrawable
public ShapeDrawable(Shape s)
From source file:com.cxy.firststudio.refresh.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }/*from w w w .j a v a 2s . c o m*/ if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); // ViewHelper.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = (int) mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.showArrowOnFirstStart(true); mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); if (getVisibility() == VISIBLE) { mProgressDrawable.setStartEndTrim(0, (float) 0.8); } }
From source file:io.puzzlebox.bloom.ui.BloomFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_bloom, container, false); // requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // setContentView(R.layout.main); // getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title); progressBarAttention = (ProgressBar) v.findViewById(R.id.progressBarAttention); final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; ShapeDrawable progressBarAttentionDrawable = new ShapeDrawable( new RoundRectShape(roundedCorners, null, null)); String progressBarAttentionColor = "#FF0000"; progressBarAttentionDrawable.getPaint().setColor(Color.parseColor(progressBarAttentionColor)); ClipDrawable progressAttention = new ClipDrawable(progressBarAttentionDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);// w w w. j a va 2 s . c om progressBarAttention.setProgressDrawable(progressAttention); progressBarAttention .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); progressBarMeditation = (ProgressBar) v.findViewById(R.id.progressBarMeditation); ShapeDrawable progressBarMeditationDrawable = new ShapeDrawable( new RoundRectShape(roundedCorners, null, null)); String progressBarMeditationColor = "#0000FF"; progressBarMeditationDrawable.getPaint().setColor(Color.parseColor(progressBarMeditationColor)); ClipDrawable progressMeditation = new ClipDrawable(progressBarMeditationDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarMeditation.setProgressDrawable(progressMeditation); progressBarMeditation .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); progressBarSignal = (ProgressBar) v.findViewById(R.id.progressBarSignal); ShapeDrawable progressBarSignalDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null)); String progressBarSignalColor = "#00FF00"; progressBarSignalDrawable.getPaint().setColor(Color.parseColor(progressBarSignalColor)); ClipDrawable progressSignal = new ClipDrawable(progressBarSignalDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarSignal.setProgressDrawable(progressSignal); progressBarSignal.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); // progressBarSignal.setProgress(tgSignal); progressBarPower = (ProgressBar) v.findViewById(R.id.progressBarPower); ShapeDrawable progressBarPowerDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null)); String progressBarPowerColor = "#FFFF00"; progressBarPowerDrawable.getPaint().setColor(Color.parseColor(progressBarPowerColor)); ClipDrawable progressPower = new ClipDrawable(progressBarPowerDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); progressBarPower.setProgressDrawable(progressPower); progressBarPower.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); // progressBarRange = (ProgressBar) v.findViewById(R.id.progressBarRange); //// ShapeDrawable progressBarRangeDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null)); // ShapeDrawable progressBarRangeDrawable = new ShapeDrawable(); //// String progressBarRangeColor = "#FF00FF"; // String progressBarRangeColor = "#990099"; // progressBarRangeDrawable.getPaint().setColor(Color.parseColor(progressBarRangeColor)); // ClipDrawable progressRange = new ClipDrawable(progressBarRangeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); // progressBarRange.setProgressDrawable(progressRange); // progressBarRange.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); // //// progressBarRange.setMax(128 + 127); // progressBarRange.setMax(bloomRangeMax); // progressBarBloom = (ProgressBar) v.findViewById(R.id.progressBarBloom); // ShapeDrawable progressBarBloomDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null)); // String progressBarBloomColor = "#7F0000"; // progressBarBloomDrawable.getPaint().setColor(Color.parseColor(progressBarBloomColor)); // ClipDrawable progressBloom = new ClipDrawable(progressBarBloomDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); // progressBarBloom.setProgressDrawable(progressBloom); // progressBarBloom.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); seekBarAttention = (SeekBar) v.findViewById(R.id.seekBarAttention); seekBarAttention.setOnSeekBarChangeListener(this); seekBarMeditation = (SeekBar) v.findViewById(R.id.seekBarMeditation); seekBarMeditation.setOnSeekBarChangeListener(this); // imageViewStatus = (ImageView) v.findViewById(R.id.imageViewStatus); servoSeekBar = (SeekBar) v.findViewById(R.id.ServoSeekBar); servoSeekBar.setEnabled(false); // servoSeekBar.setMax(180); servoSeekBar.setMax(100); servoSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { byte[] buf = new byte[] { (byte) 0x03, (byte) 0x00, (byte) 0x00 }; buf[1] = (byte) servoSeekBar.getProgress(); BloomSingleton.getInstance().characteristicTx.setValue(buf); BloomSingleton.getInstance().mBluetoothLeService .writeCharacteristic(BloomSingleton.getInstance().characteristicTx); } }); // rssiValue = (TextView) v.findViewById(R.id.rssiValue); connectBloom = (Button) v.findViewById(R.id.connectBloom); connectBloom.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (!BloomSingleton.getInstance().scanFlag) { scanLeDevice(); Timer mTimer = new Timer(); mTimer.schedule(new TimerTask() { @Override public void run() { if ((BloomSingleton.getInstance().mDevice != null) && (BloomSingleton.getInstance().mDevice.getAddress() != null) && (BloomSingleton.getInstance().mBluetoothLeService != null)) { BloomSingleton .getInstance().mDeviceAddress = BloomSingleton.getInstance().mDevice .getAddress(); if (BloomSingleton.getInstance().mDeviceAddress != null) BloomSingleton.getInstance().mBluetoothLeService .connect(BloomSingleton.getInstance().mDeviceAddress); else { Toast toast = Toast.makeText(getActivity(), "Error connecting to Puzzlebox Bloom", Toast.LENGTH_SHORT); toast.setGravity(0, 0, Gravity.CENTER | Gravity.BOTTOM); toast.show(); } BloomSingleton.getInstance().scanFlag = true; } else { getActivity().runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(getActivity(), "Error connecting to Puzzlebox Bloom", Toast.LENGTH_SHORT); toast.setGravity(0, 0, Gravity.CENTER | Gravity.BOTTOM); toast.show(); } }); } } }, BloomSingleton.getInstance().SCAN_PERIOD); } } catch (Exception e) { Log.e(TAG, "Exception connecting to Bloom: " + e); Toast toast = Toast.makeText(getActivity(), "Exception connecting to Puzzlebox Bloom", Toast.LENGTH_SHORT); toast.setGravity(0, 0, Gravity.CENTER | Gravity.BOTTOM); toast.show(); } System.out.println(BloomSingleton.getInstance().connState); // Log.e(TAG, connState); // if (connState == false) { if (!BloomSingleton.getInstance().connState && BloomSingleton.getInstance().mDeviceAddress != null) { BloomSingleton.getInstance().mBluetoothLeService .connect(BloomSingleton.getInstance().mDeviceAddress); } else { if (BloomSingleton.getInstance().mBluetoothLeService != null) { setBloomRGBOff(); BloomSingleton.getInstance().mBluetoothLeService.disconnect(); BloomSingleton.getInstance().mBluetoothLeService.close(); setButtonDisable(); } } } }); // Button buttonOpen = (Button) v.findViewById(R.id.buttonOpen); // buttonOpen.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // byte[] buf = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; // BloomSingleton.getInstance().characteristicTx.setValue(buf); // BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); // } // }); // buttonOpen.setVisibility(View.GONE); // // Button buttonClose = (Button) v.findViewById(R.id.buttonClose); // buttonClose.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // byte[] buf = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00 }; // BloomSingleton.getInstance().characteristicTx.setValue(buf); // BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); // } // }); // buttonClose.setVisibility(View.GONE); // buttonDemo = (Button) v.findViewById(R.id.buttonDemo); // buttonDemo.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // byte[] buf; //// if (! BloomSingleton.getInstance().demoActive) { // BloomSingleton.getInstance().demoActive = true; // // // bloomOpen() //// buf = new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x00}; //// BloomSingleton.getInstance().characteristicTx.setValue(buf); //// BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); // // // loopRGB() // buf = new byte[]{(byte) 0x06, (byte) 0x00, (byte) 0x00}; // BloomSingleton.getInstance().characteristicTx.setValue(buf); // BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); // // // Set Red to 0 // buf = new byte[]{(byte) 0x0A, (byte) 0x00, (byte) 0x00}; // R = 0 // BloomSingleton.getInstance().characteristicTx.setValue(buf); // BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); // // // bloomClose() //// buf = new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00}; //// BloomSingleton.getInstance().characteristicTx.setValue(buf); //// BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); // // //// } else { //// BloomSingleton.getInstance().demoActive = false; ////// buf = new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00}; ////// BloomSingleton.getInstance().characteristicTx.setValue(buf); ////// BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); //// buf = new byte[]{(byte) 0x0A, (byte) 0x00, (byte) 0x00}; // R = 0 //// BloomSingleton.getInstance().characteristicTx.setValue(buf); //// BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); ////// buf = new byte[]{(byte) 0x0A, (byte) 0x01, (byte) 0x00}; // G = 0 ////// BloomSingleton.getInstance().characteristicTx.setValue(buf); ////// BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); ////// buf = new byte[]{(byte) 0x0A, (byte) 0x02, (byte) 0x00}; // B = 0 ////// BloomSingleton.getInstance().characteristicTx.setValue(buf); ////// BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx); //// } // } // }); if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(getActivity(), "Bluetooth LE not supported", Toast.LENGTH_SHORT).show(); getActivity().finish(); } final BluetoothManager mBluetoothManager = (BluetoothManager) getActivity() .getSystemService(Context.BLUETOOTH_SERVICE); BloomSingleton.getInstance().mBluetoothAdapter = mBluetoothManager.getAdapter(); if (BloomSingleton.getInstance().mBluetoothAdapter == null) { Toast.makeText(getActivity(), "Bluetooth LE not supported", Toast.LENGTH_SHORT).show(); getActivity().finish(); return v; } Intent gattServiceIntent = new Intent(getActivity(), RBLService.class); // bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); getActivity().bindService(gattServiceIntent, mServiceConnection, getActivity().BIND_AUTO_CREATE); /** * Update settings according to default UI */ updateScreenLayout(); // updatePowerThresholds(); // updatePower(); if (BloomSingleton.getInstance().connState) setButtonEnable(); return v; }
From source file:com.vuze.android.remote.activity.LoginActivity.java
@SuppressWarnings("deprecation") private void setBackgroundGradient() { ViewGroup mainLayout = (ViewGroup) findViewById(R.id.main_loginlayout); assert mainLayout != null; int h = mainLayout.getHeight(); int w = mainLayout.getWidth(); View viewCenterOn = findViewById(R.id.login_frog_logo); assert viewCenterOn != null; RectShape shape = new RectShape(); ShapeDrawable mDrawable = new ShapeDrawable(shape); int color1 = AndroidUtilsUI.getStyleColor(this, R.attr.login_grad_color_1); int color2 = AndroidUtilsUI.getStyleColor(this, R.attr.login_grad_color_2); RadialGradient shader;//from w w w.j a va 2 s . com if (w > h) { int left = viewCenterOn.getLeft() + (viewCenterOn.getWidth() / 2); int top = viewCenterOn.getTop() + (viewCenterOn.getHeight() / 2); int remaining = w - left; shader = new RadialGradient(left, top, remaining, new int[] { color1, color2 }, new float[] { 0, 1.0f }, Shader.TileMode.CLAMP); } else { int top = viewCenterOn.getTop() + (viewCenterOn.getHeight() / 2); shader = new RadialGradient(w / 2, top, w * 2 / 3, color1, color2, Shader.TileMode.CLAMP); } mDrawable.setBounds(0, 0, w, h); mDrawable.getPaint().setShader(shader); mDrawable.getPaint().setDither(true); mDrawable.getPaint().setAntiAlias(true); mDrawable.setDither(true); mainLayout.setDrawingCacheEnabled(true); mainLayout.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); mainLayout.setAnimationCacheEnabled(false); mainLayout.setBackgroundDrawable(mDrawable); }
From source file:com.android.demos.module.animation.materialloadingprogressbar.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }/*from www . j av a 2s.com*/ if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = (int) mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); mProgressDrawable.start(); }
From source file:com.spectrum.widget.materialloadingprogressbar.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }//from ww w.ja va 2 s. c o m if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = (int) mShadowRadius; // set padding so the inner image sits correctly within the // shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.showArrowOnFirstStart(true); mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); if (getVisibility() == VISIBLE) { mProgressDrawable.start(); } }
From source file:com.janacare.janacareproject.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }//w w w . j ava2 s .c o m if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = (int) mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); if (getVisibility() == VISIBLE) { mProgressDrawable.start(); } }
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
private static Drawable createButtonShape(Context context, int color) { // Translation of Lollipop's xml button-bg definition to Java int paddingH = context.getResources().getDimensionPixelSize(R.dimen.button_padding_horizontal_material); int paddingV = context.getResources().getDimensionPixelSize(R.dimen.button_padding_vertical_material); int insetH = context.getResources().getDimensionPixelSize(R.dimen.button_inset_horizontal_material); int insetV = context.getResources().getDimensionPixelSize(R.dimen.button_inset_vertical_material); float[] outerRadii = new float[8]; Arrays.fill(outerRadii, CORNER_RADIUS); RoundRectShape r = new RoundRectShape(outerRadii, null, null); ShapeDrawable shapeDrawable = new ShapeDrawable(r); shapeDrawable.getPaint().setColor(color); shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV); return new InsetDrawable(shapeDrawable, insetH, insetV, insetH, insetV); }
From source file:com.qa.custom.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }//w w w. j a v a 2 s . c o m if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); if (getVisibility() == VISIBLE) { mProgressDrawable.start(); } }
From source file:com.aspsine.swipetoloadlayout.widget.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }/*from w w w . ja v a2 s . c o m*/ if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = (int) mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.showArrowOnFirstStart(true); mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); if (getVisibility() == VISIBLE) { mProgressDrawable.start(); } }
From source file:com.msport.clientmaster.view.CircleProgressBar.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; }/*from w ww .j a v a 2 s. com*/ if (getBackground() == null && mCircleBackgroundEnabled) { final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); if (elevationSupported()) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2); mBgCircle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint()); mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } mBgCircle.getPaint().setColor(mBackGroundColor); setBackgroundDrawable(mBgCircle); } mProgressDrawable.setBackgroundColor(mBackGroundColor); mProgressDrawable.setColorSchemeColors(mColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mArrowWidth < 0 ? mProgressStokeWidth * 4 : mArrowWidth, mArrowHeight < 0 ? mProgressStokeWidth * 2 : mArrowHeight); if (isShowArrow()) { mProgressDrawable.showArrowOnFirstStart(true); mProgressDrawable.setArrowScale(1f); mProgressDrawable.showArrow(true); } super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); if (getVisibility() == VISIBLE) { mProgressDrawable.start(); } }