use of android.graphics.drawable.shapes.Shape in project NineOldAndroids by JakeWharton.
the class ShapeHolder method setHeight.
public void setHeight(float height) {
Shape s = shape.getShape();
s.resize(s.getWidth(), height);
}
use of android.graphics.drawable.shapes.Shape in project NineOldAndroids by JakeWharton.
the class ShapeHolder method setWidth.
public void setWidth(float width) {
Shape s = shape.getShape();
s.resize(width, s.getHeight());
}
use of android.graphics.drawable.shapes.Shape in project UltimateAndroid by cymcsg.
the class AddFloatingActionButton method getIconDrawable.
@Override
Drawable getIconDrawable() {
final float iconSize = getDimension(R.dimen.fab_icon_size);
final float iconHalfSize = iconSize / 2f;
final float plusSize = getDimension(R.dimen.fab_plus_icon_size);
final float plusHalfStroke = getDimension(R.dimen.fab_plus_icon_stroke) / 2f;
final float plusOffset = (iconSize - plusSize) / 2f;
final Shape shape = new Shape() {
@Override
public void draw(Canvas canvas, Paint paint) {
canvas.drawRect(plusOffset, iconHalfSize - plusHalfStroke, iconSize - plusOffset, iconHalfSize + plusHalfStroke, paint);
canvas.drawRect(iconHalfSize - plusHalfStroke, plusOffset, iconHalfSize + plusHalfStroke, iconSize - plusOffset, paint);
}
};
ShapeDrawable drawable = new ShapeDrawable(shape);
final Paint paint = drawable.getPaint();
paint.setColor(mPlusColor);
paint.setStyle(Style.FILL);
paint.setAntiAlias(true);
return drawable;
}
use of android.graphics.drawable.shapes.Shape in project KJFrameForAndroid by kymjs.
the class ShapeHolder method setHeight.
public void setHeight(float height) {
Shape s = shape.getShape();
s.resize(s.getWidth(), height);
}
use of android.graphics.drawable.shapes.Shape in project uk.co.jasonfry.android.tools by jsonfry.
the class PageControl method initPageControl.
private void initPageControl() {
Log.i("uk.co.jasonfry.android.tools.ui.PageControl", "Initialising PageControl");
indicators = new ArrayList<ImageView>();
activeDrawable = new ShapeDrawable();
inactiveDrawable = new ShapeDrawable();
activeDrawable.setBounds(0, 0, mIndicatorSize, mIndicatorSize);
inactiveDrawable.setBounds(0, 0, mIndicatorSize, mIndicatorSize);
Shape s1 = new OvalShape();
s1.resize(mIndicatorSize, mIndicatorSize);
Shape s2 = new OvalShape();
s2.resize(mIndicatorSize, mIndicatorSize);
int[] i = new int[2];
i[0] = android.R.attr.textColorSecondary;
i[1] = android.R.attr.textColorSecondaryInverse;
TypedArray a = mContext.getTheme().obtainStyledAttributes(i);
((ShapeDrawable) activeDrawable).getPaint().setColor(a.getColor(0, Color.DKGRAY));
((ShapeDrawable) inactiveDrawable).getPaint().setColor(a.getColor(1, Color.LTGRAY));
((ShapeDrawable) activeDrawable).setShape(s1);
((ShapeDrawable) inactiveDrawable).setShape(s2);
mIndicatorSize = (int) (mIndicatorSize * getResources().getDisplayMetrics().density);
setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (mOnPageControlClickListener != null) {
switch(event.getAction()) {
case MotionEvent.ACTION_UP:
if (PageControl.this.getOrientation() == LinearLayout.HORIZONTAL) {
if (//if on left of view
event.getX() < (PageControl.this.getWidth() / 2)) {
if (mCurrentPage > 0) {
mOnPageControlClickListener.goBackwards();
}
} else //if on right of view
{
if (mCurrentPage < (mPageCount - 1)) {
mOnPageControlClickListener.goForwards();
}
}
} else {
if (//if on top half of view
event.getY() < (PageControl.this.getHeight() / 2)) {
if (mCurrentPage > 0) {
mOnPageControlClickListener.goBackwards();
}
} else //if on bottom half of view
{
if (mCurrentPage < (mPageCount - 1)) {
mOnPageControlClickListener.goForwards();
}
}
}
return false;
}
}
return true;
}
});
}
Aggregations