imagebutton

Android ImageButton - determine what resource is currently set

微笑、不失礼 提交于 2019-11-29 09:42:39
Is there a way I can find what resource a particular ImageButton is set to, at any given time? For eg: I have an ImageButton that I set to R.drawable.btn_on onCreate. Later, at some point, the ImageButton gets set to R.drawable.btn_off . I want to be able to check what resource the ImageButton is set to in my code. Thanks Chris Just use setTag() and getTag() to associate and retrieve custom data for your ImageView . You could define your own class as a child of ImageButton , add a private int variable and set it when setImageResource(int) is called. Something like: public class MyImageButton

Change viewpager fragment by a buttonClick

落花浮王杯 提交于 2019-11-29 08:25:29
问题 I'm trying to change the viewpager fragment by clicking on a button. I have 5 fragments, each fragment has it's own xml file (frag1.xml, frag2.xml, and so on). Every fragment has it's 5 buttons that should go to other pages of the viewpager. But the problem is how do I check in the FragmentPageAdapter which button is clicked and how to get there? I'll show the code I have then it should be clear I think. Think of it like a homescreen that has dots at the bottom and I you click a certain dot,

Creating a triangular shaped button for android application

跟風遠走 提交于 2019-11-29 07:28:16
I need to create 2 buttons arranged like this in my android application: But the problem is that the button I have created is not a perfect traingle shaped button. In fact it is a square button with the image set as background. Here in this case there is a problem such that the white areas near the image is clickable and I want the buttons to be more close.Which means that the white space in between the two button has to be eliminated to maximum. When I use relative layout, the problem is that, when I click on 1 button, sometimes the other button also gets clicked automatically. This is

Gridview with layout (imageview + imagebutton) for every value

谁说胖子不能爱 提交于 2019-11-29 07:25:34
Is it possible to make a gridview that has instead of a grid of pictures, a grid of pictures with a small imagebutton below every one of them? Short answer: Yes. You can have an ImageView and an ImageButton in a GridView . Long answer: You will naturally have to create a custom GridView for that purpose. For example: Create an XML which will hold the container GridView , say, grid.xml : <GridView android:id="@+id/gridFriends" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clipChildren="true" android:columnWidth="100dp" android:fastScrollEnabled="true" android

Android: How to prevent image from being scaled in ImageView or ImageButton?

人盡茶涼 提交于 2019-11-29 04:15:25
问题 How can I prevent my bitmap from being scaled automatically in an ImageView or ImageButton if the view or button is stretched using "fill_parent" or using "weight"? This will be useful, for example, to create a 4-button toolbar at the top of the screen where the buttons are equally spaced, but the images inside the buttons keep getting streched even if I use scaleType="center", which should prevent scaling according to the doc, but it doesn't. Any insight is appreciated! Thanks, 回答1: I have

Disable an ImageButton

半城伤御伤魂 提交于 2019-11-28 22:27:42
问题 This looks easy, but I'm not able to disable an ImageButton . It continues to receive click events, and its appearance don't change like a standard Button would. There are some similar questions on SO, but they don't help me. Even with a very simple layout like this : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ImageButton android:id="@+id/btn_call" android

How to remove ImageButton's standard background image?

孤街浪徒 提交于 2019-11-28 17:21:34
In ImageButton I want to remove the standard button background image. In http://developer.android.com it is said, that one must define his\her own background image or set the background color to be transparent. I tried to set a black background, but it didn't make any effect... You can use android:background="@null" for your ImageButton . ImageButton.setBackgroundResource(0) Filipe Brito The best choice is not set a transparent background to your ImageButton . Give to your user a feedback when the button is tapped. android:background="?attr/selectableItemBackgroundBorderless" No, it has to be

Apply Material Design Touch Ripple to ImageButton?

妖精的绣舞 提交于 2019-11-28 16:08:33
问题 I have an imagebutton that doesn't respond with a touch animation when it is clicked because it is a static image unlike regular buttons on lollipop which come with the built in ripple effect. I would like to add the material design ripple touch effect to the image but can't seem to find a way to implement it. I can set a color filter over the image but that is not the ripple effect. An example of what I'm trying to do is when you hold an album cover image in Google Play Music and a shadow

Can I create an ASP.NET ImageButton that doesn't postback?

泪湿孤枕 提交于 2019-11-28 13:34:10
I'm trying to use the ImageButton control for client-side script execution only. I can specify the client-side script to execute using the OnClientClick property, but how do I stop it from trying to post every time the user clicks it? There is no reason to post when this button is clicked. I've set CausesValidation to False, but this doesn't stop it from posting. Here's one way you could do it without conflicting with the postback functioning of other controls: Define your button something like this: <asp:Button runat="server" Text="Button" UseSubmitBehavior="false" OnClientClick="alert('my

disable an ImageButton?

感情迁移 提交于 2019-11-28 10:42:04
I wanted to leave an ImageButton is disabled (not clickable) but have used android: enabled = "false" and does't work. Does anyone know how to disable an ImageButton ? If you want to show the button as disabled (if you have that set up in an xml drawable file) doing both setClickable(false) AND setEnabled(false) will do the trick. You can use the android:clickable attribute on the XML, or the setClickable(boolean) method from your code. user2924714 When setting a clicklistener for the ImageButton , under the hood android resets the attribute clickable to true . That's why setting android