Create animation of image on button - android

I am trying to create a library for android basically it's a indeterminate progress bar on button itself and even text next to it look the pic for reference it is inspired from snapchat
So basically i need a button with icon and text and the icon should perform animation on the button itself
I tried using drawableLeft but i can't perform the animation
I also tried using linerlayout with imageView and textView inside it in xml and then perform animation on imageView but since i am creating lib all i want is in a class file
So any suggestion or idea how I can solve the problem?

Related

Android Studio how to make a custom button with soft Transparen background

I've tried using Android Studio to create a button with a blurry transparent background, as shown in this picture, but unfortunately, I do not know how to implement it
Here is a picture of how I imagine the button
Use this library, you can create a blur layout and use it as button with setOnClickListener
https://github.com/CameraKit/blurkit-android

Android ImageButton - How to hide the image while showing the background?

I've read the API and Googled but perhaps I've missed something: All the visibility options on an ImageButton seem to talk about this view as a whole. So, what should I do if I want to hide the image but keep the background(except for explicitly setting the image to something transparent that is)? I'm doing a Pairs Game and when one clicks on the element it should show the image and if the next click doesn't match the image should be hidden, but the grey background of the button should remain.
Thanks!
So, what should I do if I want to hide the image
Try setting it to #null or create transparent PNG in your drawables and set it.
in XML, remove android:src="something" and in the code remove imgbtn.setImageBitmap(null);
Instead of using ImageButton you can use ImageView with a FrameLayout on top of it. Set the background of FrameLayout as gray color and then show/hide this FrameLayout/Image as per your requirement. Take relative layout for each and make it clickable. On the click event of this layout, do the changes as required.

Since animation can only be set as background, how to have a background?

I have ImageButtons that take a background, this background provides a standard shape for my buttons. But I have a special image button that is an animation. Animations only work if they are placed using setBackground.
So, how can I have my normal button background, and still have the animation graphically nested inside of it? Is there some kind of drawable that would let me nest a background?
The reason I need a separate background is the onPress states that it provides.
I accomplished this with a FrameLayout so that I can have the original imagebutton and the animated imageview on top of each other

what is use of image button?

I'm new to Android application development.
I would like to ask the use of image button in Android programming when simple button can also add the image with the button. How can we generate click event of image button?
The Image Button control is a special type of button that displays a Drawable graphic instead of text.
The Image Button and Button controls are both derived from the View class, but
they are unrelated to each other. The Button class is actually a direct subclass
of Text View (think of it as a line of text with a background graphic that looks
like a button), whereas the Image Button class is a direct subclass of Image View.
If you will look in the API for Button you will see that it has a method called setOnClickListener that is inherited from View. Since ImageButton is also a view, you can also call the same method for it.
The only way that I see to use an image in a Button is by using android:background in the XML. This is only used for setting what's shown behind the text of a button. You should use ImageButton when you want to make a button that only uses the image as its defining feature. If you end up wanting to only see the image and have no part of the button background visible, you can set android:background on the button to use an invisible Drawable.

Push button effect with Imagebutton

I have been working on an app, which basically consists of imagebuttons.
I want to achieve the push button effect with imagebutton.
Is it possible to achieve..
you can programmatically do using setColorFilter or setAlpha (it depends on the effect you want) to your buttons when you do some action (in this case i suppose onPress).
These are methods inherited from ImageView:
ImageView Reference

Categories

Resources