I want to have a button like the one in the link below. How can i achieve it just by java code or xml? By the way it's going to be of a different color when pressed. I've explored similar posts but none helped. Any help appreciated.
The button which i want
Just make a View with large rectangle and add what you want(e.g. Label contains 'Number Of Students' and/or something else) in the view.
Then, add onClickListener to the View.
To change clicked colour, refer to here
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 want to have a row of squared shaped buttons. It should act like radio buttons so that only one can be selected at a time. But it should seem like ToggleButtons. Which is having a square shape that contains the text and when the user clicks it toggles.
How can I do this? Can anyone give me a sample? I'm willing to do it in XML not
programmatically.
I want it to look like this with texts inside
EDIT: A better way to ask this question:
How can I customize a RadioButon group in a way that they look like ordinary Buttons?
I have an image which include 10 boxes on my image view. When I click the one of boxes I want to change color of box (fill with color). How do I do that? Should I use Surface View or something else?
Update:
I found a solution. But if I use AsyncTask the code does not work. If I use a normal class the code works. I do not know why but I think problem is related with invalidate().
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.
Hey guy's
First of all thanks for reading this.
I'm having trouble to find a way to change my EditText when I loose focus to it.
I would like it to be greyed out when this happens, but I don't want it to be disabled because the user can touch it and edit the text later.
Anyone?
Greetings!
You can set different colors to the text based on an OnFocusChangeListener
Another option is to set a style in xml. See this question for details: Android: change style when focused
To change the opacity, use setAlpha. In this answer I show it how to do it in an animation: Two questions about custom app ui's and AlphaAnimation