首页 > 代码库 > Bootstrap Button 使用方法

Bootstrap Button 使用方法

Getting Started

<!-- basic button --><com.beardedhen.androidbootstrap.BootstrapButton    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_margin="10dp"    android:text="Success"    bootstrapbutton:bb_icon_right="fa-android"    bootstrapbutton:bb_type="success"/>

The above code inserts a default button with a android icon to the right. The following attributes can be added to any BootstrapButton

bootstrapbutton:bb_type="default" The type of button as per the Bootstrap CSS Buttons

bootstrapbutton:bb_icon_left="fa-heart" the icon to the left of the text, as per the Font Awesome Cheat Sheet

bootstrapbutton:bb_icon_right="fa-trophy" the icon to the right of the text, as per the Font Awesome Cheat Sheet

bootstrapbutton:bb_roundedCorners="true" whether the button should have rounded corners, the defaults is false

android:enabled="false" disabled buttons appear more opaque, the default is true (buttons are enabled)

bootstrapbutton:bb_size="large" Size of the button e.g. large, default, small, xsmall

android:textSize="12sp" Text size must always be in sp!

The button height (padding between text and button top/bottom) is not editable appart by using bb_size which also impact the text size. See this question for a workaround.

You can also edit the button programmatically!

button.setText("title"); changes the text displayed

button.setLeftIcon("fa-star"); changes the left icon

button.setRightIcon("fa-heart"); changes the right icon

button.setBootstrapType("success"); changes the type of bootstrap button

button.setBootstrapButtonEnabled("false"); change whether the button is enabled or disabled!