Search in sources :

Example 11 with RectShape

use of android.graphics.drawable.shapes.RectShape in project wire-android by wireapp.

the class AccentColorEditText method updateCursor.

protected void updateCursor() {
    ShapeDrawable cursorDrawable = new ShapeDrawable(new RectShape());
    cursorDrawable.setIntrinsicWidth(ViewUtils.toPx(getContext(), DEFAULT_CURSOR_WIDTH_DP));
    cursorDrawable.getPaint().setColor(accentColor);
    setHintCursorSize(cursorDrawable);
    try {
        // now attach the resource so it stops using the old one
        Field ef = ReflectionUtils.getInheritedPrivateField(this.getClass(), "mEditor");
        if (ef == null) {
            return;
        }
        ef.setAccessible(true);
        Object editorObject = ef.get(this);
        Field df = ReflectionUtils.getInheritedPrivateField(editorObject.getClass(), "mCursorDrawable");
        if (df == null) {
            return;
        }
        df.setAccessible(true);
        Object dfo = df.get(editorObject);
        if (dfo == null || !(dfo instanceof Drawable[])) {
            return;
        }
        Drawable[] darray = (Drawable[]) dfo;
        for (int i = 0; i < darray.length; i++) {
            darray[i] = cursorDrawable;
        }
    } catch (IllegalAccessException | IllegalArgumentException ex) {
        Timber.e(ex, "Error accessing private field");
    }
}
Also used : Field(java.lang.reflect.Field) RectShape(android.graphics.drawable.shapes.RectShape) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Drawable(android.graphics.drawable.Drawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Example 12 with RectShape

use of android.graphics.drawable.shapes.RectShape in project UltimateAndroid by cymcsg.

the class DefaultSectionAdapter method getItemView.

@Override
@SuppressWarnings(value = { "deprecation" })
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
    TextView tv = null;
    if (convertView != null) {
        tv = (TextView) convertView;
    } else {
        tv = new TextView(context);
        RectShape rs = new RectShape();
        ShapeDrawable sd = new BottomBorderBackground(rs, Color.WHITE, Color.GRAY);
        tv.setBackgroundDrawable(sd);
        tv.setPadding(20, 0, 0, 0);
        tv.setGravity(Gravity.CENTER_VERTICAL);
    }
    tv.setLayoutParams(new LayoutParams(300, itemHeight));
    tv.setText("s" + section + " p" + position);
    return tv;
}
Also used : RectShape(android.graphics.drawable.shapes.RectShape) LayoutParams(android.view.ViewGroup.LayoutParams) ShapeDrawable(android.graphics.drawable.ShapeDrawable) TextView(android.widget.TextView)

Example 13 with RectShape

use of android.graphics.drawable.shapes.RectShape in project UltimateAndroid by cymcsg.

the class ProgressbarWheelActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.progress_wheel_activity);
    pw_two = (ProgressWheel) findViewById(R.id.progressBarTwo);
    pw_three = (ProgressWheel) findViewById(R.id.progressBarThree);
    pw_four = (ProgressWheel) findViewById(R.id.progressBarFour);
    //pw_five = (ProgressWheel) findViewById(R.id.progressBarFive);
    ShapeDrawable bg = new ShapeDrawable(new RectShape());
    int[] pixels = new int[] { 0xFF2E9121, 0xFF2E9121, 0xFF2E9121, 0xFF2E9121, 0xFF2E9121, 0xFF2E9121, 0xFFFFFFFF, 0xFFFFFFFF };
    Bitmap bm = Bitmap.createBitmap(pixels, 8, 1, Bitmap.Config.ARGB_8888);
    Shader shader = new BitmapShader(bm, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
    pw_three.setRimShader(shader);
    pw_three.spin();
    pw_four.spin();
    final Runnable r = new Runnable() {

        public void run() {
            running = true;
            while (progress < 361) {
                pw_two.incrementProgress();
                progress++;
                try {
                    Thread.sleep(15);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            running = false;
        }
    };
    Button spin = (Button) findViewById(R.id.btn_spin);
    spin.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            if (!running) {
                if (pw_two.isSpinning) {
                    pw_two.stopSpinning();
                }
                pw_two.resetCount();
                pw_two.setText("Loading...");
                pw_two.spin();
            }
        }
    });
    Button increment = (Button) findViewById(R.id.btn_increment);
    increment.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            if (!running) {
                progress = 0;
                pw_two.resetCount();
                Thread s = new Thread(r);
                s.start();
            }
        }
    });
}
Also used : RectShape(android.graphics.drawable.shapes.RectShape) Bitmap(android.graphics.Bitmap) Button(android.widget.Button) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OnClickListener(android.view.View.OnClickListener) BitmapShader(android.graphics.BitmapShader) Shader(android.graphics.Shader) BitmapShader(android.graphics.BitmapShader) View(android.view.View)

Aggregations

ShapeDrawable (android.graphics.drawable.ShapeDrawable)13 RectShape (android.graphics.drawable.shapes.RectShape)13 Shader (android.graphics.Shader)6 LinearGradient (android.graphics.LinearGradient)5 PaintDrawable (android.graphics.drawable.PaintDrawable)5 Drawable (android.graphics.drawable.Drawable)4 ClipDrawable (android.graphics.drawable.ClipDrawable)3 LayoutParams (android.view.ViewGroup.LayoutParams)2 TextView (android.widget.TextView)2 Bitmap (android.graphics.Bitmap)1 BitmapShader (android.graphics.BitmapShader)1 Paint (android.graphics.Paint)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 StateListDrawable (android.graphics.drawable.StateListDrawable)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 Button (android.widget.Button)1 Field (java.lang.reflect.Field)1