Posts

Showing posts with the label Android Custom View

Android: Start The Circular Progress Bar From Top (270°)

Image
Answer : Try specifying rotation degrees to your progress items. <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@android:id/progress"> <rotate android:fromDegrees="270" android:toDegrees="270" android:pivotX="50%" android:pivotY="50%" > <shape android:innerRadiusRatio="2.5" android:shape="ring" android:thicknessRatio="25.0" > <gradient android:centerColor="@color/gray" android:endColor="@color/gray" android:startColor="@color/gray" android:type="sweep" /> </shape> </rotate>...

Android Canvas Clear With Transparency

Answer : Use the following. canvas.drawColor(Color.TRANSPARENT,Mode.CLEAR); The solution was to create a secondary canvas and bitmap to draw on. My Custom View's onSizeChanged() method looked like @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.TRANSPARENT); temp = new Canvas(bitmap); } and the onDrawMethod looks like @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); temp.drawColor(Color.argb(80, 0, 0, 0)); temp.drawCircle(centerPosX, centerPosY, 200, transparentPaint); canvas.drawBitmap(bitmap, 0, 0, null); } where transparentPaint is declared in the onstructor as transparentPaint = new Paint(); transparentPaint.setColor(getResources().getColor(android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode....

Android- How To Implement Horizontal Step Progress Bar

Image
Answer : I found a Vertical Steper that follows Google Material Design guidelines: And also another well documented library Here I hope it helps. EDIT: A repo which seems to currently be well supported and used (Sep 2016) https://github.com/baoyachi/StepView Old Answer: This answer is late to the party, but so far the best I've found is this repo from Anton46: https://github.com/anton46/Android-StepsView It's quite simple to setup too. Heres an example: I've created a Step View ViewPager that supports both Horizontal and Vertical paging and doesn't require drawables and images. You can configure the appearance by simply specifying various attributes. It can be found here https://github.com/YablokovDmitry/StepViewPager