Questions tagged [android-imagebutton]

Displays a button with an image (instead of text) that can be pressed or clicked by the user.

Displays a button with an image (instead of text) that can be pressed or clicked by the user.
By default, an ImageButton looks like a regular Button, with the standard button background that changes color during different button states.
The image on the surface of the button is defined either by the android:src attribute in the XML element or by the setImageResource(int) method.

To remove the standard button background image, define your own background image or set the background color to be transparent.

To indicate the different button states (focused, selected, etc.), you can define a different image for each state.
E.g., a blue image by default, an orange one for when focused, and a yellow one for when pressed. An easy way to do this is with an XML drawable "selector."

Reference page: http://developer.android.com/reference/android/widget/ImageButton.html

511 questions
90
votes
5 answers

How to set ImageButton property of app:srcCompat="@drawable/pic" programmatically?

How to set the ImageButton property of app:srcCompat="@drawable/pic" programmatically? Something like myImageButton.setBackgroundResource(R.drawable.eng2); but the property of app:srcCompat.
Isaac Darlong
  • 1,101
  • 1
  • 7
  • 12
52
votes
5 answers

What's the name of the little widget with three dots inside a cardview in android?

What's the little widget with three dots? How can I add it to my app?
Cristofor
  • 2,077
  • 2
  • 15
  • 23
36
votes
2 answers

Is there a way to fill parent minus a fixed number in Android RelativeLayout?

I have an ImageButton that I want to fill its parent RelativeLayout container for its width but minus a few dp so it has some left and right padding. I tried fill_parent-10dp but that causes an error and doesn't render.
31
votes
3 answers

Implementing Ripple effect outside ImageButton

I am trying to implement ripple effect for ImageButton.I have set ripple in background and drawable image in the src for it. android:background="@drawable/myripplexml" android:src="@drawable/myimagepath" Its giving nice ripple effect inside button…
13
votes
7 answers

Android - change send icon's color on ImageButton

How to change the default color of send icon on this ImageButton?
Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81
8
votes
1 answer

How to return to home screen from Activity

I know Android will return to the home screen when I press the Home key, however, I want my imageButton to behave as the Home key, which can inform the home screen to the foreground. How should I implement my onClickListener to accomplish this?
user718146
  • 400
  • 1
  • 4
  • 16
8
votes
6 answers

Error inflating class ImageButton

I have an app which has fragment and image button on that. The problem is it's working on and above 5.0 but not below 5.0. The min sdk version is 17. Not getting what's wrong here. I am getting 2 exceptions. One is RuntimeException for image…
7
votes
1 answer

How to rotate buttons when orientation changes without rotating the layout?

I want to make an ImageButton rotate when the device orientation changes. It should rotate for 90, 180, 270 and 360 angles and its relative layout should remain steady so only the buttons move. How can this be done? I've done some research but found…
7
votes
2 answers

Android ImageButton setColorFilter Not Working

I've look for posts that answer this issue, but none of them are working for me, so I think I have a fundamental misunderstanding of just how it's supposed to work. I have an ImageButton which has a png file applied to it. The png is mostly…
Ken
  • 139
  • 2
  • 8
7
votes
2 answers

How do i make multiple pages that i can go to in the app with buttons and make the imagebuttons link to these pages?

So this is my first app and I am trying to code and need some help with buttons. After searching for a answer I just couldn't find one that I understood. I want to be able to make different pages for the app and make imagebuttons that link to these…
Noobcoder
  • 91
  • 1
  • 1
  • 3
6
votes
2 answers

Object is not abstract and does not implement abstract member public abstract fun onClick(p0: View!): Unit

I haven't found anything over the past day that shows how to do this action, everything I've seen is with a basic button of which I am unable to replicate for use with an image button. using setOnClickListener does not seem to work at all though the…
RealTechyGod
  • 121
  • 1
  • 1
  • 11
6
votes
2 answers

How to change the solid color programmatically of a shape in Android?

I'm trying to change the solid color of a shape in my Fragment.
Edito
  • 3,030
  • 13
  • 35
  • 67
6
votes
2 answers

How to make custom shape buttons that overlap each other in Android

I have 6 separate images with a transparent background. How can I put all those images together as buttons, like: From what I read I guess I have to use Frame Layout in order to have overlapping buttons. I need each color is a separate button when…
kelly rose
  • 63
  • 5
5
votes
2 answers

Why is the same layout_weight leading to different widths for Android ImageButton and Button?

I'm getting some weird behavior in my LinearLayout when I try to set regular Buttons and an ImageButton to the same layout_weight. The image button's android:src resource is extrememly small and fits well inside the ImageButton without any problems.…
5
votes
2 answers

Is there a way I can gray out an ImageButton in Android without maintaining a separate gray copy of the original Image?

I am trying to have an ImageButton that initially has a gray effect on it & turns into its original color when selected. I'm trying to achieve something like . I know this can be done in CSS, but was wondering if any Android attribute / function…
Auro
  • 1,578
  • 3
  • 31
  • 62
1
2 3
34 35