I have a confusion about ImageButton. I can make an ImageView clickable and use as button, so why do we explicitly need an ImageButton? When designing Android app, I found ImageView is much more useful than ImageButton, perhaps I missed some of the features of ImageButton. So I want to know what are the advantages of using ImageButton? Thanks.
This question was answered quite thoroughly here: Difference between a clickable ImageView and ImageButton
To sum it up: There's no differences, except default style. ImageButton has a non-null background by default.
Related
Yesterday I asked a question about the TextView. I read and I see that it's very difficult to understand. So, I'm sorry.
Now I explain better my problem:
I try to personalize my TextView. I tried two different things:
I use photoshop, I made an image text and I use it as a drawable. The image re-sized isn't with right quality
I try to use the text of TextView, but I can't change the family of the text (the app crashed). Then I don't know how to set gradient as text color and border in the text.
What can I do?
Edit: yes! For the point 1 I use an ImageView inside of TextView. In point 2 I use TextView. I have problem in both situation!
I think to customize textview (any view) you have to implement your own custom view by creating your custom class.
Here is link for custom text view,i hope i will find it useful
http://www.jayway.com/2012/06/25/creating-custom-android-views-part-1-extending-standard-views-and-adding-new-xml-attributes/
I would like to know how to make the button which contains a kinda icon.
I made up a LinearLayout first and the button belongs in it.
I tried the the icon to be in the Button by using 'android:drawableLeft="#drawable/*"
The icon was placed to too Left for me.
The button is a little bit long and text and icon are small so there are some space empty.
I mean, I want the icon to be more closer to the text than it was.
Now, icon is placed to the left and text is in center.
I want them to be together with a little padding.
I tried to use 'android:drawablePadding=7dip' but it didnt work.
I so want somebody to let me know how to do it.
Have a good day.
Thank you
You can use Custom Buttons are resizes button stretch image size and below link for custom Button Tutorial link
http://www.thesecretpie.com/2010/07/creating-custom-fancy-buttons-in.html
Thanks..!
There are two techniques. I suggest you look into:
Image Buttons
Image Views
With Image view you can create a button by using an onclick listener which can be created from within your activity or from your xml layout file.
Visit this website.
https://zapier.com/
See this portion of the website.
I wan that same in my android application that text changes after some time
For this i use count down timer to introduce delay between the text view changes. but it doesnt work.
NOTE:please be more specific in asking questions.
Also have you tried anything yet..
It can simply be achieved by a TimerTask repeating in desired interval,, In which the textView .setText(new value).
If you desire exact view as shown than the TextView width and height would be wrap content with text color white and background color black.
You might want to subclass from TextView adding a timer and text1 text2 attributes, and calling setText(text1) or setText(text2) on timer ticks.
Just to be clear, I'm a co-founder of Zapier and we are not associated with this question nor do we condone adding vague questions to Stack Overflow. ;-)
If you can clarify what you are interested in (the animations? the timer? the css?) I'd be happy to talk about what we're doing. Not really sure what the reference to Android means.
How can a button (Button) receive a drawable and center it on the button without the text?
If you can not do this, how then do to the background does not "stretch" button at all?
The problem is that for some button have icon and text, for others only the icon and the third type only text! So I have to use an object alone, more stylish, rather than several different classes.
Google needs to improve this architecture! If I want a button with or without text, occluding the center with the image, it is my problem, I should be able to do!
For your first request: use ImageButton if you wanna have Both, text and drawable, or combinations of that I think you have to subclass button yourself. You can look inside the code of TabWidget how to do that (because TabWidget can already have both but was intended to start Activities)
Use a layout, such as AbsoluteLayout, LinearLayout, or RelativeLayout with a TextView and ImageView to create your custom clickable layout and views. Also check this article about layout reuse.
I did my homework and this question has been asked a few times, but never answered with a solution to the problem. The question is, how do you change the size of the checkbox button in a checkbox compound button?
In my case I have a checkbox with a custom button attribute pointing to a selector xml file containing items for each possible state pointing to png images. I want to be able to specify in dp the size that these images are displayed as the button for the checkbox.
The answer to this question is NOT to change the android:layout_width of the checkbox itself. Anyone know how to do this?
Also, things I've tried include adding widths and heights to the selector and items. I've tried adding my selector to a Button and resizing the button (which works for the button alone), but I can't figure out how to specify to the CheckBox that it should use that Button xml.
I just ran into this problem myself. My checkbox has no text, and in that case this works well:
set
android:background="#my_selector_drawable"
instead of the button attribute. To avoid the standard button on top of the image, set
android:button="#null"
Now you can set the size of the checkbox with the normal android:layout_width & android:layout_height.
If you want a checkbox with text as well, this wont work
Well for now the best I can do seems to be to build my own checkbox using a button by keeping a boolean for the state that gets inverted in the OnClickListener and calling setBackgroundResource to swap between the "checked" and "unchecked" drawables.
Meh. At least I can resize the button to be exactly what I want. Hopefully someone will come up with a better way to do it.