This is the output i am getting.
as you can see the progress bar has white borders that i cant get rid off. I want the loading to jus comprise of the beige ball and the custom animation inside it. I used a dialog for this.
below is my code:
ActivityIndicator extends the dialog.
public class ActivityIndicator extends Dialog {
private ProgressBar progressBar;
public ActivityIndicator(@NonNull Context context) {
super(context);
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_indicator);
this.setCancelable(false);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
ThreeBounce threeBounce = new ThreeBounce();
progressBar.setIndeterminateDrawable(threeBounce);
}
}
ThreeBounce is a custom library that i imported for the animation.
activityIndicator.xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/loading_ball>
</ProgressBar>
<com.github.ybq.android.spinkit.SpinKitView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/spin_kit"
style="@style/SpinKitView.ThreeBounce"
android:layout_width="68dp"
android:layout_height="59dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:background="@drawable/loading_ball"
app:SpinKit_Color="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
loading_ball.xml:(Custom circle image view)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/loadingball"/>
<item android:drawable="@drawable/circle"/>
</layer-list>
circle.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="1.5dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="0dp"
android:color="@android:color/white" />
</shape>
i tried setting the progress bar background to transparent but it doesnt seem to work. Is there any way to achieve this?
First create a class Loader
public class Loader extends Dialog{
public Loader(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public Loader(Context context, int theme) {
super(context, theme);
// TODO Auto-generated constructor stub
setContentView(R.layout.loader_layout);
}
public Loader(Context context, boolean cancelable,
OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
// TODO Auto-generated constructor stub
}
}
and it's Layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#00ffffff">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ffffff"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<com.github.ybq.android.spinkit.SpinKitView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/spin_kit"
style="@style/SpinKitView.ThreeBounce"
android:layout_width="68dp"
android:layout_height="59dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:background="@drawable/loading_ball"
app:SpinKit_Color="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
and Call the loader by this method
Loader loader = new Loader(this,android.R.style.Theme_Translucent_NoTitleBar);
loader.show();
loader.setCancelable(false);
loader.setCanceledOnTouchOutside(false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.