android - button style
-
Normal button looks like: Now, please let me know, How can i make a simple button same as an attached image button (i.e. button corner shape is round and also there is no gap between two buttons)
-
Answer:
9-patch would work fine here, but I try to avoid them since it's hard for me to do them :( You can try having a selector and using a shape for each state: The shape would look like this: <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#AAFFFFFF"/> <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
Bhuro at Stack Overflow Visit the source
Other answers
Here are some great-looking gradient button examples including a preview: http://www.dibbus.com/2011/02/gradient-buttons-for-android/
Bachi
You need to create a http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch drawable. In order to have no gap (margin) between the buttons you need to create the appropriate layout in XML and set the margin to 0.
kgiannakakis
look for foursquared source code and look for SegmentedButton.java file, this is the file that implement these buttons shown in the image.
Thiago
Create a Nine patch drawable which is easy with http://developer.android.com/guide/developing/tools/draw9patch.html (part of android/tools) and then apply styles and themes... the tutorial at http://blog.androgames.net/40/custom-button-style-and-theme/ should get you started.
Mike
I would like to share one article which is worth to implement for Button. Here is an article: http://www.dibbus.com/2011/03/9patch-images-in-android/ , its really nice and awesome article.
Paresh Mayani
You can also use ImageView in your xml file and than give onClickable and onFocusable true and then create onClick event method on backend code and give the name of the method on xml , so that instead of dealing with all shape or button issues you just put the imageview there and make it act like a button.Here is sample code for you <ImageView android:id="@+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:focusable="true" android:onClick="testClickEvent" android:paddingRight="8dip" android:paddingBottom="8dip" android:src="@drawable/testImg"/> As I said on backend side create method with sign like this and this will do the job public void testClickEvent(View v){} Then implement what you wanna do in this method
Burak Dede
Related Q & A:
- How To Style Shy Scene Hair?Best solution by Yahoo! Answers
- How to change color of radio button when checked radio button?Best solution by Stack Overflow
- How to implement your own like button in Android?Best solution by Stack Overflow
- How to draggable button background color to apply another button background?Best solution by Stack Overflow
- Where can I find the best Chicago-style and New York Style pizza in San Diego?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.