Android – How to center button on screen

A small Android tip to show you how to center button on screen. Wrap button in RelativeLayout, and set following attributes to “true“. android:layout_centerVertical="true" android:layout_centerHorizontal="true" Following is a full example to demonstrate the use of above tip to center a button on screen. 1. Android Layout A button in layout. File : res/layout/main.xml <?xml version="1.0" …

Read more

Android button example

In Android, just use “android.widget.Button” class to display a normal button. In this tutorial, we show you how to display a normal button, add a click listener, when user click on the button, open an URL in your Android’s internet browser. P.S This project is developed in Eclipse 3.7, and tested with Android 2.3.3. Note …

Read more

Android ToggleButton example

In Android, the “android.widget.ToggleButton” is a special class to render a button which has only two states, for example, “on and “off”. It’s best alternative to radio buttons to turn on or turn off a function. In this tutorial, we show you how to use XML to create two toggle buttons and a normal button, …

Read more

JSF 2 button and commandButton example

In JSF 2.0, both <h:button /> and <h:commandButton /> tags are used to render HTML input element of type button, with different mechanism to handle the navigation. 1. JSF h:commandButton example The “h:commandButton” tag is released since JSF 1.x, you can declare the bean, which return the navigation outcome in the “action” attribute. If browser’s …

Read more