Wich is the best approach to create rounded and cool styled buttons with the 80% of the width of the screen?

I'm developing a Android app.

I have a menu screen on my app, wich must have some buttons. I need that the buttons haves allways the 80% of de width of the creen and these buttons must be cool styled, with rounded sides and some style on them, not bad looking buttons. Also these buttons must contain the text I want to put on them.

I tryed to do this creating png buttons and scaling them on android (by java code) but this way is a bad way.

I want to learn a better way to do this, for example, creating views directly with java code and overwiting onDraw method. Which is the best approach for achieve my needs?

code examples are welcome

Answers


Modify the built-in buttons with a color filter to give them a different color. This keeps their cool shape and shading. Use android:weight in the layout xml to make them occupy 80% of the screen width.

Button.getBackground().setColorFilter(0x64034C8C,PorterDuff.Mode.MULTIPLY);

This example uses 8 hex digits to define the color. The first two digits specify the transparency, while the others define the RGB values of the color.


I think you might benefit from looking into 9 patch mechanism. There are many tutorials on how to do so.

http://developer.android.com/tools/help/draw9patch.html

http://radleymarx.com/blog/simple-guide-to-9-patch/


If you don't want to use 9-patches, but still want to create styled buttons you could use Shapes. This blog post may help you.


Need Your Help

upload photo with retrofit2: retrofit: 2.0.0-beta4

android retrofit2

I have problem with upload photo on server with uses retrofit 2.Can somebody help me? what i did wrong? my back-end dev has sad me that boundary in header didnt generate =(

AngularJS/Typescript Integration Pattern - Scope Methods

javascript angularjs typescript

I am attempting change the way I am writing AngularJS apps from a plain-javascript to using TypeScript as a pre-processor.