imagebutton

Android : Using selector to change button background image and color

被刻印的时光 ゝ 提交于 2019-12-13 15:04:45
问题 I have a button I set its background to specific selector . The selector currently changes the button background and changed an image as the background. I also want the background color to be changed (the image is icon with transparent space around). This is the selector : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <!-- default --> <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable

ImageButton Stretching Background Image

♀尐吖头ヾ 提交于 2019-12-13 14:24:10
问题 I am trying to create an ImageButton with no border but I am running into an issue with the sizing of the image button. Using Eclipse ADT I drag an ImageButton to the layout and select my background image. The image button appears as follows: As you can see there is a border between the background image and the image button perimeter which I would like to get rid of. To do so, I set the padding property to 0dp. The image button now looks like this: Finally, I set the scale type to fitXY:

New activity not opening

这一生的挚爱 提交于 2019-12-13 08:25:43
问题 I'm an italian student developing an Android application with the latest version of Android Studio and with Android API 26 (Android Oreo). The application is very simple: 1. Main activity, "MySchoolSyllabus": it shows a list of school subjects, represented by images placed in the "res" project's folder. 2. Second activity, "Materia" (it means "subject"): once the user clicks on a subject image, this activity needs to be opened, showing another list of images, representing that subject's

WPF styling . Have no idea how to do it

北城余情 提交于 2019-12-13 04:58:54
问题 I am trying to make an image button in WPF based on the following article Custom button template in WPF The problem with this is that I have No Idea how to make the image to become grayscale when disabling the button. So I am loading two images, But I can not load a second images into ButtonProperties. So my idea was to load an rgb and greyscale image, and as I disable the button one image is hidden and another shown, and vice versa. and also the text to get greyed out. As I think, this

Refresh ListView in ImageButton.onClick inside getView off a BaseAdapter

前提是你 提交于 2019-12-13 02:45:11
问题 I have an activity that is generated by a custom BaseAdapter and look like this: This is the getView off the custom BaseAdapter: @Override public View getView(int position, View view, ViewGroup parent) { final Visita visita = getItem(position); view = mInflater.inflate(R.layout.visita_item, null); //The ListView Item ImageButton btnUp, btnDown; btnUp = (ImageButton)view.findViewById(R.id.visita_btn_move_up); btnDown = (ImageButton)view.findViewById(R.id.visita_btn_move_down); btnUp =

what is use of image button?

老子叫甜甜 提交于 2019-12-13 02:13:23
问题 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? 回答1: 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

Alpha animation not working

这一生的挚爱 提交于 2019-12-12 14:28:56
问题 Pretty simple: I add a dynamic button on screen and I try to fade it out after adding, but the animation never plays. I tried adding it later when it is already rendered on the screen, but still nothing. Below is the code: btn = new ImageButton(context); btn.setBackgroundColor(0xFFFF0000); params = new WindowManager.LayoutParams( width,height, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |

how to change the ImageButton's image when it is pressed and released?

一曲冷凌霜 提交于 2019-12-12 08:00:13
问题 I want that in my android application, the ImageButton change its image when it is pressed and released, and when it is pressed released again, the image for ImageButton will be changed back , how to do that? 回答1: create a selector (it is an xml file) put in drawable folder. and in xml five path of that xml instaed of actual image android:background="@drawable/imageselector" or in program also you can get the same using imageview.setBackgroundDrawable(R.drawable.imageselector) Following is my

How to set transparent background for Image Button in code?

半腔热情 提交于 2019-12-12 07:09:29
问题 I can set ImageButton background transparent in layout.xml using: android:background="@android:color/transparent" How I can acomplish same thing using java code? Something like ib.setBackgroundColor(???); 回答1: This is the simple only you have to set background color as transparent ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01); btn.setBackgroundColor(Color.TRANSPARENT); 回答2: Do it in your xml <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"

How to initialize an image button?

帅比萌擦擦* 提交于 2019-12-12 05:37:53
问题 Hoping again for someone to explain me a probably basic question. I´ve setup an imagabutton like this: class overviewImageButton: NSButton { override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) self.image = NSImage(named: "buttonImage.png") } } Now, if I start the application, the image is not shown from start. Pressing the (empty) button, the image shows up. Someone knows how to initialize the button to show the image from start? Thanks a lot! 回答1: The problem is that you are