leandroborgesferreira / loadingbuttonandroid Goto Github PK
View Code? Open in Web Editor NEWA button to substitute the ProgressDialog
License: MIT License
A button to substitute the ProgressDialog
License: MIT License
Is it possible to use .png or VectorDrawable as button background?
When I try to do so, it looks like this:
even though corner angle was specified:
circular:finalCornerAngle="50dp"
circular:initialCornerAngle="0dp" // also tried "50dp"
Can I make it round circular after calling .startAnimation();
and then return back to rectangular shape after .revertAnimation();
?
I have successfully implemented this library in my dem app but now what I want is the button to go back to it's state before pressing it. Similar to what is displayed on the main page of this library. This is my code so far:
circularProgressButton = (CircularProgressButton) findViewById(R.id.sign_in_button);
circularProgressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AsyncTask<String, String, String> signInActivity = new AsyncTask<String, String, String>() {
@Override
protected String doInBackground(String... params) {
try{
Thread.sleep(3000);
} catch (InterruptedException e){
e.printStackTrace();
}
return "done";
}
@Override
protected void onPostExecute(String s) {
if(s.equals("done")){
circularProgressButton.doneLoadingAnimation(Color.parseColor("#FF4081"), BitmapFactory.decodeResource(getResources(), R.drawable.ic_done_white_48dp));
Toast.makeText(MainActivity.this, "Welcome!", Toast.LENGTH_SHORT).show();
}
}
};
circularProgressButton.startAnimation();
signInActivity.execute();
}
});
I am trying to implement this for my login functionality. I want the button to go back to it's initial state but I can't understand how is it possible here?
Any help here would be appreciated!
followBtn.revertAnimation(new OnAnimationEndListener() {
@OverRide
public void onAnimationEnd() {
if (selectedUser.isFollowing) {
followBtn.setText("Unfollow");
} else {
followBtn.setText("Follow");
}
}
});
....
followBtn.revertAnimation();
Como faz pra mudar o texto do botão após uma animação? Após um revertAnimation() eu não consigo alterar o texto do botão.
This is my xml, and the spinning is still black and the button is still full width of the layout
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/pointsButton"
android:layout_width="150dp" (or wrap_content)
android:layout_height="wrap_content"
android:background="@color/blue"
android:text="Sumar"
android:layout_marginTop="15dp"
android:layout_below="@id/number_picker"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
app:spinning_bar_color="@color/white"
app:spinning_bar_width="4dp"/>
When calling doneLoagingAnimation
after startAnimation()
, but before the start animation has ended, the application crashes on a nullpointer:
Attempt to invoke virtual method
'void br.com.simplepass.loading_button_lib.animatedDrawables.CircularAnimatedDrawable.stop()' on a null object reference at
br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.doneLoagingAnimation(CircularProgressButton.java:228)
As said, it happens in the following situation:
startAnimation()
doneLoagingAnimation(params)
before the initial start animation has ended (button getting narrower)In my case I'm running an async task that finishes really quick. Because the button depends on its own start animation, this might be an issue that can arise anytime; especially when using wide buttons on tablet and devices get faster in the future.
Another tiny note: is doneLoagingAnimation
a typo? (Loaging vs Loading)
When i call stopAnimation()
(without calling revertAnimation()
) the animation does not stop and the loading progress continues running.
Here's my code:
followButton.startAnimation();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// Do something after 5s = 5000ms
followButton.stopAnimation();
followButton.setText("\u2713");
followButton.setTextSize(18);
}
}, 5000);
Great library. Looks great.
I got a 49KB memory leak when having two of these buttons in an Activity
. I clicked on both of them and they did the full item animation.
btnCollection.startAnimation();
...
btnCollection.revertAnimation(() ->
{
if (inCollection)
btnCollection.setText("Remove from Collection");
else
btnCollection.setText("Add to Collection");
});
I thought it might be due to assigning the OnAnimationEndListener
but when I tried with:
btnCollection.revertAnimation();
btnCollection.setText("Remove from Collection");
I also got the 49KB leak.
EDIT: The leak does not occur if I do not press the button
Any ideas?
LeakCanary log:
I am not able to find latest version to add in gradle file. Can anyone please help me out?
If I rotate the screen while the button is in progress, the button completely disappears even though I call startAnimation straight after orientation change happened. When I try to debug startAnimation in that case, in the following code mParams.mInitialWidth = getWidth();
mParams.mInitialHeight = getHeight();
getWidth() and getHeight() both return 0.
Should I do something special in order to make the button remember its state on orientation change?
I using CircularProgressImageButton. Then when I call revertAnimation with callback, only is changed the background, isn't changing ImageDrawable and SpinningBarColor.
btnPersonFollow.revertAnimation(new OnAnimationEndListener() {
@Override
public void onAnimationEnd() {
boolean followingOrPending = Arrays.asList(FollowStatus.FollowStatusAccepted, FollowStatus.FollowStatusPending, FollowStatus.FollowStatusRejected).contains(getPerson().followingStatus);
if (followingOrPending) {
btnPersonFollow.setBackgroundResource(R.drawable.bg_button_following);
btnPersonFollow.setImageResource(R.drawable.person_check);
btnPersonFollow.setSpinningBarColor(ResourcesCompat.getColor(viewHolder.itemView.getResources(),R.color.suda_blue_medium,null));
} else {
btnPersonFollow.setBackgroundResource(R.drawable.bg_button_following_outline);
btnPersonFollow.setImageResource(R.drawable.person_add);
btnPersonFollow.setSpinningBarColor(ResourcesCompat.getColor(viewHolder.itemView.getResources(),R.color.suda_cyan,null));
}
}
});
When starting the animation it morphs in a circle but progress border stops in between. Any way around?
Hi,
When I change background color of the CircularProgressButton in use, the button doesn't get round during animation.
Here is my xml:
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton android:id="@+id/valider_date_livraison" android:layout_width="match_parent" android:layout_height="40dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@color/bleu" android:text="SUIVANT" android:textColor="@color/blanc" android:textSize="16dp" app:font="Gotham-Bold.otf" app:spinning_bar_width="3dp" app:spinning_bar_color="@color/blanc" app:spinning_bar_padding="6dp" app:initialCornerAngle="0dp"> </br.com.simplepass.loading_button_lib.customViews.CircularProgressButton>
And here is the change of background color in the code:
valider_date_livraison.setBackgroundColor(Color.GREEN);
see the result on animation start:
Thanks for your help,
Théo
@drawable/circular_border_shape
Button does not morph when we don't set any background to the button.
Here is my xml
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/welcome_signin_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/form_horizontal_margin"
android:theme="@style/AppTheme.Button"
style="@style/progressButtonStyle"
android:text="@string/welcome_signin_cta"
/>
And here is the styles applyed
<style name="AppTheme.Button">
<item name="android:textAllCaps">false</item>
<item name="android:colorButtonNormal">?attr/colorAccent</item>
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
</style>
<style name="progressButtonStyle" parent="Widget.AppCompat.Button">
<item name="finalCornerAngle">50dp</item>
<item name="initialCornerAngle">2dp</item>
<item name="spinning_bar_color">@color/white</item>
<item name="spinning_bar_padding">4dp</item>
<item name="spinning_bar_width">2dp</item>
</style>
Beautiful animation. I have a problem when init call mBtLogin.startAnimation(), animation not load full in onCreate. I fix it as put startAnimation in a Handler().postdelay. How to direct call startAnimation() when start app.
Thanks.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CircularProgressButton mBtLogin = (CircularProgressButton) findViewById(R.id.progress_btn_change_activity);
mBtLogin.startAnimation();
/*new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mBtLogin.startAnimation();
}
}, 100);*/
}
app:spinning_bar_color="#FFFFFFFF", it doesn't work.I use white. It's still black.
I can see the button in Android Studio XML(Preview) but when I run the code on my mobile I cannot see the button on my screen. Please help me with it. Thanks
The library works on android 5.1 and above(both emulators and real phones) and there is no problem. However, when I ran my app on the emulator(19 level API), the app got crashed.
I don't know whether there is the same problem on the real phone running 19 API.
Stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.app.test, PID: 4578 java.lang.NullPointerException at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505) at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517) at android.animation.ValueAnimator.start(ValueAnimator.java:936) at android.animation.ValueAnimator.start(ValueAnimator.java:946) at android.animation.ObjectAnimator.start(ObjectAnimator.java:465) at android.animation.AnimatorSet.start(AnimatorSet.java:563) at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.d(CircularProgressButton.java:513) at com.app.test.MainActivity.m(MainActivity.java:123) at com.app.test.MainActivity.onClick(MainActivity.java:54) at android.view.View.performClick(View.java:4438) at android.view.View$PerformClick.run(View.java:18422) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
The app crashes at line circularProgressButton.startAnimation();
Is the library compatible with emulators? And does it work with prelollipop devices?
Unable to use library in project due to manifest merger failure. Perhaps increasing the Build Tools version to 25.0.2 will fix the problem?
the button resize all the way from right to left. the progress end up being on the left part of the screen looking awful
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ivHeader"
android:layout_marginTop="-26dp"
android:background="@mipmap/bg_logincard"
android:elevation="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:layout_marginStart="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/btnLogin"
style="@style/BoldFont"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_btn_rounded"
android:paddingBottom="16dp"
android:paddingTop="16dp"
android:text="@string/session_btnlbl_login"
android:textAllCaps="false"
android:textColor="@color/text_btn_light"
android:textSize="17sp"
app:spinning_bar_color="#FFF"
app:spinning_bar_padding="6dp"
app:spinning_bar_width="4dp"
app:finalCornerAngle="90dp"
app:initialCornerAngle="90dp"
android:gravity="center"
>
</br.com.simplepass.loading_button_lib.customViews.CircularProgressButton>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Hi,
I'm trying to use the CircularProgressButton, but I receive this error:
Caused by: android.view.InflateException: Binary XML file line #147: Binary XML file line #147: Error inflating class br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
Caused by: android.view.InflateException: Binary XML file line #147: Error inflating class br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
This is my XML:
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/login"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="15dp"
android:background="@drawable/button_rectangle"
android:text="Accedi"
android:textAllCaps="false"
android:textColor="@drawable/text_color_button"
android:textSize="18sp" />
Could you help me? Thanks
Hi,
Using https://github.com/square/leakcanary, I've got sometimes report of memory leaks; but I don't succeed to reproduce it all times.
I can't share you a full details (privacy issues), only the trace of leak.
Thanks,
Regards
* my.awesome.android.app.AwesomeActivity has leaked:
* GC ROOT org.chromium.ui.base.ActivityWindowAndroid.mVSyncMonitor
* references org.chromium.ui.VSyncMonitor.mChoreographer
* references android.view.Choreographer.mCallbackQueues
* references array android.view.Choreographer$CallbackQueue[].[1]
* references android.view.Choreographer$CallbackQueue.mHead
* references android.view.Choreographer$CallbackRecord.action
* references android.animation.AnimationHandler$1.this$0 (anonymous implementation of android.view.Choreographer$FrameCallback)
* references android.animation.AnimationHandler.mAnimationCallbacks
* references java.util.ArrayList.elementData
* references array java.lang.Object[].[0]
* references android.animation.AnimatorSet.mNodeMap
* references android.util.ArrayMap.mArray
* references array java.lang.Object[].[2]
* references android.animation.ValueAnimator.mUpdateListeners
* references java.util.ArrayList.elementData
* references array java.lang.Object[].[0]
* references br.com.simplepass.loading_button_lib.animatedDrawables.CircularAnimatedDrawable$3.this$0 (anonymous implementation of android.animation.ValueAnimator$AnimatorUpdateListener)
* references br.com.simplepass.loading_button_lib.animatedDrawables.CircularAnimatedDrawable.mAnimatedView
* references br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.mContext
* leaks my.awesome.android.app.AwesomeActivity instance
* Retaining: 1.00 MB.
* Reference Key: SOMETHING_THAT_LOOKS_LIKE_UUID_V4
* Device: Google google Android SDK built for x86 sdk_gphone_x86
* Android Version: 8.0.0 API: 26 LeakCanary: 1.5.1 1be44b3
* Durations: watch=5012ms, gc=116ms, heap dump=602ms, analysis=9154ms
Hi, i found a issue in your library when i use .revertAnimation() method.
If i use twice the method on a button, nullpointerException occurred. Why?
the message:
"Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.revertAnimation(CircularProgressButton.java:279)"
Hi, I am trying to keep the border (stroke) of my custom background when doneLoadingAnimation
is called. Instead, I can only select the same color of my custom background but the stroke is lost in the process.
My custom background (request_button_background.xml
) is:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="12dp" />
<solid android:color="@color/green" />
<stroke
android:width="1.5dp"
android:color="@color/colorPrimaryDark" />
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
</shape>
My CircularProgressButton is defined as:
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/btn_request"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="30dp"
android:textAlignment="center"
android:background="@drawable/request_button_background"
android:layout_marginEnd="20dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|right"
app:spinning_bar_width="4dp"
app:spinning_bar_color="@color/white"
app:spinning_bar_padding="2dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:textSize="15sp"
android:textColor="@color/black"
android:textAllCaps="false"
android:text="Request RSVP"/>
Finally I call the doneLoadingAnimation
as follows
btn.doneLoadingAnimation(ContextCompat.getColor(EventInfoActivity.this, R.color.green),
BitmapFactory.decodeResource(EventInfoActivity.this.getResources(),
R.drawable.ic_check2));
Thanks for the support and the awesome library.
Bernat
I've already tried almost everything... but the progress keeps starting at the start position of the button and not in the center as it should..
(você é br, então... quando clico no botão, ao invés do progress ir pro meio da tela, ele fica no começo!!!)
Running your code on an Android 6 Device with Kotlin and Anko, I get the following error:
Caused by: java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.GradientDrawable
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.init(CircularProgressButton.java:116)
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.<init>(CircularProgressButton.java:64)
at com.example.anko.loadingbutton.CircularprogresbuttonKt.circularProgressButton(circularprogresbutton.kt:9)
at com.example.app.ui.LoginActivityUi.createView(loginactivity.kt:95)
at com.example.app.ui.LoginActivityUi.createView(loginactivity.kt:55)
at org.jetbrains.anko.AnkoContextKt.setContentView(AnkoContext.kt:138)
at com.example.app.ui.LoginActivity.onCreate(loginactivity.kt:34)
at android.app.Activity.performCreate(Activity.java:6372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2432)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2539)
at android.app.ActivityThread.access$900(ActivityThread.java:168)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5665)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
I tried delivering StateListDrawable.getCurrent()
as background resource, but still no luck:
backgroundDrawable = (context.drawable(R.drawable.button_shape_default) as StateListDrawable).current
This is my code for integration with anko:
fun ViewManager.circularProgressButton(theme : Int = 0, init : CircularProgressButton.() -> Unit = {})
= ankoView({ CircularProgressButton(it) }, theme, init)
fun ViewManager.circularProgressButton(text : CharSequence, theme : Int = 0, init : CircularProgressButton.() -> Unit = {})
= circularProgressButton(theme) { init(); setText(text) }
fun ViewManager.circularProgressButton(@StringRes textRes : Int, theme : Int = 0, init : CircularProgressButton.() -> Unit = {})
= circularProgressButton(theme) { init(); setText(textRes) }
Looking at the source code, it seems that you are only looking for the type of the Drawable if the passed AttributeSet is not null. While this is the case when inflating from xml layout, programmatically creating the button will hit that bug.
Hello, nice library, I do have some issues though:
I have a custom font but android:fontFamily on the button is completely ignored.
I also have a custom selector for the button background with rounded corners that doesn't seem to work. The button stays gray like it is constant in the enabled=false state.
When I remove the first item in my selector then the button has the right color, but doesn't take the other color when pressed.
Hope those issues can be resolved.
So long
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:background="@drawable/rounded_corners_button"
android:fontFamily="@font/brandon_bold"
android:text="@string/login"
android:textColor="@color/black"
app:spinning_bar_color="@color/black"
app:spinning_bar_padding="6dp"
app:spinning_bar_width="4dp"/>`
<item android:state_enabled="false">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/midLightGray"/>
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
</item>
<item android:state_pressed="true">
<shape>
<solid android:color="@color/primaryDark"/>
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
</item>
<item android:state_focused="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/primary"/>
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
</item>
<item android:state_focused="false">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/primary"/>
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
</item>
<item android:state_pressed="false">
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/primary"/>
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
</item>
Hello,
Why min sdk version is 17 ? i couldn't add to my project that have min sdk 16
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library [br.com.simplepass:loading-button-android:1.8.1] C:\Users\hptn.gradle\caches\transforms-1\files-1.1\loading-button-android-1.11.1.aar\09162386e44c5299c9cec1c77f0f0787\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 17,
or use tools:overrideLibrary="br.com.simplepass.loading_button_lib" to force usage (may lead to runtime failures)
any solution ?
thanks
text that set in xml always show in capital. is that any way to look similar what written in xml
In Debug mode its is working but when i build for release mode the circle animation is not showing.
any suggestions?
I tried to add in proguard-rules to keep CircularProgressButton but never worked.
Drawables in buttons like android:drawableLeft
are disappearing after revertAnimation()
is called.
The CircularProgressButton won't work correctly with my gradient_button.xml background. In fact it doesn't change the color when I click on it. So it simply doesn't execute the android:state_pressed="true" part... Using this gradient_button.xml for a default button, it works perfectly.
layout_main.xml
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/buttonCircle"
android:text="Register Device"
app:spinning_bar_color="#fff"
app:spinning_bar_padding="6dp"
app:spinning_bar_width="4dp"
app:initialCornerAngle="24dp"
style="@style/button"
/>
style.xml
<style name="button">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:layout_marginTop">30dp</item>
<item name="android:background">@drawable/gradient_button</item>
<item name="android:paddingStart">35dp</item>
<item name="android:paddingEnd">11dp</item>
<item name="android:drawableEnd">@drawable/ic_navigate_next_24dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
gradient_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid
android:color="@color/lightgreen" />
<corners
android:radius="24dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid
android:color="@color/green" />
<corners
android:radius="24dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
When we stop animation without handler its causing nullpointer issue.
Also can you please share your example in java as well?
I put the button xml inside a FrameLayout since I am using fragments. It shows up in the Android Studio Preview window but doesn't show up in emulator or actual device. However when I move this to activity layout file with a CoordinatorLayout parent, it shows up there.
I want to use the button with shadow same like material CardView. I this possible with this library? or any alternative solution?
`<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/submit_settings"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="dimen/activity_layout_margin"
android:background="drawable/button_submit"
android:onClick="onClick"
android:text="string/api_settings_submit"
android:textColor="color/colorWhite"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/secret_layout"
android:scaleType="fitCenter"
android:src="drawable/ic_checkmark"
app:spinning_bar_padding="0dp"
app:spinning_bar_color="@color/colorBlack"
app:spinning_bar_width="3dp"
app:initialCornerAngle="0dp"
app:finalCornerAngle="0dp" />
</android.support.constraint.ConstraintLayout>`
saveButton.doneLoadingAnimation( ContextCompat.getColor(getApplicationContext(), R.color.colorBlack), BitmapFactory.decodeResource(getResources(), R.drawable.ic_checkmark));
When the contraints are set on left and right, after calling the doneLoadingAnimation. the image/bitmap is stretched out.
I tried many ways to get around this with no success and I tried Invalidate cache & tried to change compile sdk from 26 to 27, the same problem
This is the error I get:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
and this is my dependencies
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
//retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//circular image view
implementation 'com.mikhaellopez:circularimageview:3.0.2'
//Matisse selector
implementation 'com.zhihu.android:matisse:0.4.3'
implementation 'net.alhazmy13.MediaPicker:libary:2.4.0'
//swipe left recycle view
implementation 'com.tubb.smrv:swipemenu-recyclerview:5.4.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
//animation library
implementation 'com.wang.avi:library:2.1.3'
//Ok http
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
//Glide
implementation 'com.github.bumptech.glide:glide:4.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
//loading button
implementation 'br.com.simplepass:loading-button-android:1.14.0'
implementation 'com.android.support:multidex:1.0.3'
}
I have button with rounded corner. However, when I call revert revertAnimation the button become sharp with no rounded corner but it is preserve the styling
Hello!
While progress, the arc is blinking. It's like a new step when it becomes it's min size and then become full size and immediately min again and begin the growing.
Tested on android simulator API 25
hey, I want to use this loading button as a progress dialog.
Means I want when user clicks it then i should fetch lat long and user should not interact with the activity and when the lat long are successfully fetched then the loading of this button should stop. How i can do that ?
Mainly i want the functionality of progress dialog with this loading button.
If i use asyn task still the user can interact with the activity...
btn.doneLoagingAnimation(fillColor, bitmap);
Please correct the code in the readme. loaging will be loading
Thanks for the Buttons.
Might be related #17...
Original view:
View reused/recycled: got original + done loading image+filled color
If I use dispose when the view is unbind, setupAnimations()
is never called again. It will not work...
The only way I think to fix the problem, right now, is to instantiate a new view from code instead from layout...
Not tested yet, I will soon
Edit:
Setting up the Button programmatically, without attributes (new CircularProgressButton(context)
) thrown exception:
java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.GradientDrawable
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.init(CircularProgressButton.java:115)
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.<init>(CircularProgressButton.java:63)
I tried to use the "theme" attribute on a CircularProgressButton but it does not animate the button to a full circle. It remains a rectangle and the progressbar starts to spin. As soon as I remove the "theme" attribute, it starts to work again like a charm
button do't change to circle
Well, I get a NPE when calling doneLoadingAnimation. I don't get it why, actually I have some more buttons in different fragments and they are working perfectly. If I debug and compare both circularProgressButton variables, they don't have any difference. circularProgressButton is not Null.
Used version 1.8.4 and 1.12.0.
Edit: I have a callback/interface in the AsyncTask to the Fragment, which will then call this method. I guess this could be the issue?, but actually I am doing the same in the other fragments...
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sample.lexycon, PID: 16270
java.lang.NullPointerException: Attempt to invoke virtual method 'void br.com.simplepass.loading_button_lib.animatedDrawables.CircularRevealAnimatedDrawable.draw(android.graphics.Canvas)' on a null object reference
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.drawDoneAnimation(CircularProgressButton.java:316)
at br.com.simplepass.loading_button_lib.customViews.CircularProgressButton.onDraw(CircularProgressButton.java:232)
at android.view.View.draw(View.java:18319)
at android.view.View.updateDisplayListIfDirty(View.java:17297)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3950)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3930)
at android.view.View.updateDisplayListIfDirty(View.java:17260)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:666)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:672)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:780)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3112)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2908)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2502)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1509)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7051)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.