Snippets

cutiko Custom ProgressBar

Updated by cutiko

File SomeActivity.java Added

  • Ignore whitespace
  • Hide word diff
+/*Or just add this in your Activity*/
+
+loginPb.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.cta_third), PorterDuff.Mode.SRC_IN);
Updated by cutiko

File Activity_Something.xml Added

  • Ignore whitespace
  • Hide word diff
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:context="cl.cutiko.diadelpicoapp.ui.LoginActivity_">
+
+    <!-- This is an Activity example -->
+    <!-- Here im using the style to get the custom_pb but you could also simple use the background property and reference it -->
+    <ProgressBar
+        style="@style/custom_pb">
+    </ProgressBar>
+
+
+</RelativeLayout>

File style.xml Added

  • Ignore whitespace
  • Hide word diff
+<resources>
+
+  <!-- Dont need to copy this entire file just copy this in your style -->
+  <!-- see how custom_pb is reference for the background -->
+  
+  <style name="custom_pb">
+    <item name="android:layout_width">100dp</item>
+    <item name="android:layout_height">100dp</item>
+    <item name="android:layout_gravity">center_horizontal</item>
+    <item name="android:background">@drawable/custom_pb</item>
+    <item name="android:indeterminate">true</item>
+  </style>
+  
+</resources>
Created by cutiko

File custom_pb.xml Added

  • Ignore whitespace
  • Hide word diff
+<?xml version="1.0" encoding="utf-8"?>
+<rotate xmlns:android="http://schemas.android.com/apk/res/android"
+    android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
+    android:toDegrees="360">
+    <shape android:shape="ring" android:innerRadiusRatio="3"
+        android:thicknessRatio="8" android:useLevel="false">
+
+        <size android:width="100dp" android:height="100dp" />
+        <gradient android:type="sweep" android:useLevel="false"
+            android:startColor="@color/cta_main"
+            android:endColor="@color/cta_third"
+            android:angle="0"
+            />
+    </shape>
+</rotate>
+
+<!-- Im using colors here taken from the color.xml file, create your own there or just use a hex color in place -->
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.