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

495 questions
81
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
  • 987
  • 1
  • 6
  • 10
46
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?
Cristian
  • 1,847
  • 2
  • 13
  • 21
33
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.
30
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…
11
votes
6 answers

Android - change send icon's color on ImageButton

How to change the default color of send icon on this ImageButton?
Farzan Najipour
  • 2,244
  • 4
  • 30
  • 71
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
  • 370
  • 1
  • 3
  • 16
7
votes
5 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
  • 117
  • 2
  • 5
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

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

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.
Edward
  • 1,441
  • 6
  • 23
  • 41
5
votes
5 answers

Android Studio Project: bottom of UI is cut off

I'm having a problem with the bottom of my ListView and ImageButton being cut off when I load my app onto a phone or when using an emulator. I could just use margins or padding, but wouldn't that be device specific? I'd like my app to look as I…
5
votes
2 answers

How to change all ToolBar's icons color dynamically without styling toolbar

I have been looking a way to change the color of all elements in a toolbar working like an ActionBar dynamically. Specifications: Using parent="Theme.AppCompat.Light.NoActionBar" on styles.xml Appcompat v7 22 setting setSupportActionBar() in my…
5
votes
5 answers

How set the onClick event in a ImageButton?

I have created one image button in android, but when I am clicking on that button nothing is happening. I have set all the properties but still nothing is happening. So can you help me that where I am wrong. xml file
1
2 3
32 33