imagebutton

How to add a text under the image button in Android?

我的梦境 提交于 2019-12-21 10:21:56
问题 I want to add text under a image button, which are also clickable, and will be redirected to the same activity as the image button. basically it's like the app list in any android phone, e.g. 回答1: If you have your ImageButton declared in XML, then just put it into a LinearLayout which also contains a TextView and set the onClickListener on the LinearLayout . The structure would be like <LinearLayout ... > <!-- This is the LinearLayout for the xml document --> <!-- Some other layout code here

Windows Phone 7 Image Button

柔情痞子 提交于 2019-12-20 11:52:47
问题 I need to create an Image Button for my application like web-oriented style. I have an image 20x20 pixel and want an image button with the same dimension of the image. I tried to set this inside my xaml but it doesn't work: <Button Grid.Row="0" Margin="0" Padding="0" Click="AddtoFavorite_Click" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right"> <Button.Content> <Image Source="/MyNamespace;component/images/star_yellow.png" Margin="0" Width="20" Height="20" /> </Button

Windows Phone 7 Image Button

ぃ、小莉子 提交于 2019-12-20 11:52:18
问题 I need to create an Image Button for my application like web-oriented style. I have an image 20x20 pixel and want an image button with the same dimension of the image. I tried to set this inside my xaml but it doesn't work: <Button Grid.Row="0" Margin="0" Padding="0" Click="AddtoFavorite_Click" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right"> <Button.Content> <Image Source="/MyNamespace;component/images/star_yellow.png" Margin="0" Width="20" Height="20" /> </Button

How to add image(left) and text on button

喜夏-厌秋 提交于 2019-12-20 10:24:23
问题 How to add image(left) and text on button? For illustration: 回答1: use android:drawableLeft="@drawable/image" in your layout xml you can also do this from code Drawable icon= getContext().getResources().getDrawable( R.drawable.image); button.setCompoundDrawablesWithIntrinsicBounds( icon, null, null, null ); 回答2: We can also manage the size of drawable while doing programmatically Drawable dr = getResources().getDrawable(R.drawable.mag_green); dr.setBounds(0, 0, 43, 40); //Left,Top,Right,Bottom

ImageButton in Android with transparent background

﹥>﹥吖頭↗ 提交于 2019-12-20 09:35:41
问题 I have follow this post to make ImageButton in android android image button The image appears to the button but it has some background , my Image is a png image and I want the button to be transparent background any one help please 回答1: add this line to your ImageButton xml layout. android:background="@null" 回答2: Here's an alternative solution that worked for me: android:background="@android:color/transparent" As Sunny said, add it to the ImageButtons' XML layout 回答3: In your code use this:

Image button click event not firing in chrome

◇◆丶佛笑我妖孽 提交于 2019-12-20 06:26:59
问题 I noticed that in chrome if you have an asp.net image button and do a mouse down then a mouse move and finally a mouse up, a click event is not fired. It works in other browsers. Does any body have a work around to this ??? 回答1: It's because chrome starts a select/drag behavior when you do that. Try the following css. html, body, div, span, object, form, input, h1, h2, button, label, a, img { -moz-user-select: none; -webkit-user-select: none; /* this will work for QtWebKit in future */

Transparent background in ImageButton with ripple effect?

亡梦爱人 提交于 2019-12-18 11:06:00
问题 I want to programmatically remove the grey background in ImageButton. I tried many method of removing it like - imageButton.setBackgroundDrawable(null); but on implementing them, I don't get the ripple effect on the ImageButton on touch. (No highlighting on touch). Is there any way to remove the background but preserve the ripple effect or highlight. 回答1: If android:background="?attr/selectableItemBackground" this works than I believe this answer should solve your problem: https:/

Padding not working on ImageButton

走远了吗. 提交于 2019-12-18 10:47:30
问题 In an app I am working on, I have several ImageButtons. Each ImageButton has a background and content in the form of a drawable. Right now the drawable is at maximum size within the confines of the ImageButton, but I want it to scale down so I need to add some padding. The thing is that when I try to do that, it doesn't have any effect. My XML is as follows for each ImageButton: <ImageButton android:id="@+id/button_zero" android:layout_width="0dip" android:layout_height="wrap_content" android

Creating a triangular shaped button for android application

余生颓废 提交于 2019-12-18 05:01:41
问题 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

disable an ImageButton?

陌路散爱 提交于 2019-12-17 19:32:10
问题 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 ? 回答1: 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. 回答2: You can use the android:clickable attribute on the XML, or the setClickable(boolean) method from your code. 回答3: When setting a clicklistener for the