How to Add Android Bootstrap style widgets with Glyph Icons?

0
729

If you need the quick web design implementation that Bootstrap provides on your Android apps, or if you just love that Android Bootstrap look and want to put it everywhere

Android Bootstrap is an Android library which provides custom views styled according to the Twitter Bootstrap Specification. This allows you to spend more time on development rather than trying to get a consistent theme across your app, especially if you are already familiar with the Bootstrap Framework.

How to use Android Bootstrap in your project?

1Import Android Bootstrap library

Add the following dependency to your build.gradle, ensuring you replace ‘X.X.X’ with the latest version on the button above:

dependencies {
   compile 'com.beardedhen:androidbootstrap:{X.X.X}'
}

You should also override your application class with the following:

public class SampleApplication extends Application {
    @Override public void onCreate() {
        super.onCreate();
        TypefaceProvider.registerDefaultIconSets();
    }
}

You should then checkout the library and investigate the sample code, which covers most of the features.

Download

Read this : Make dynamic Android View using json2view 

2BootstrapButton

A button that supports Glyph icons, and is themeable using Bootstrap Brands.

<com.beardedhen.androidbootstrap.BootstrapButton
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="BootstrapButton"
 app:bootstrapBrand="success"
 app:bootstrapSize="lg"
 app:buttonMode="regular"
 app:showOutline="false"
 app:roundedCorners="true"
 />

BootstrapButton

3BootstrapButtonGroup

It allows BootstrapButtons to be grouped together and their attributes controlled en masse.

<com.beardedhen.androidbootstrap.BootstrapButtonGroup
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="BootstrapButtonGroup"
 android:orientation="vertical"
 app:bootstrapBrand="success"
 app:bootstrapSize="lg"
 app:roundedCorners="true"
 >
 <com.beardedhen.androidbootstrap.BootstrapButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="BootstrapButton 1"
    />
 <com.beardedhen.androidbootstrap.BootstrapButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="BootstrapButton 2"
    />
</com.beardedhen.androidbootstrap.BootstrapButtonGroup>

BootstrapButtonGroup

4AwesomeTextView

A text widget that displays Glyph icons, and is themeable using Bootstrap Brands.

<com.beardedhen.androidbootstrap.AwesomeTextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 app:bootstrapBrand="success"
 app:fontAwesomeIcon="fa_android"
 />

AwesomeTextView

Do you know how to : Building UI with ConstraintLayout in Android?

5BootstrapProgressBar

It displays progress in a bar from 0-100, and animates updates to the current progress.

<com.beardedhen.androidbootstrap.BootstrapProgressBar
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 app:animated="true"
 app:bootstrapBrand="warning"
 app:progress="78"
 app:striped="true"
 />

BootstrapProgressBar

6BootstrapProgressBarGroup

It allows BootstrapProgressBars to be group together to have the effect of stacked progress bar.

<com.beardedhen.androidbootstrap.BootstrapProgressBarGroup
         android:id="@+id/example_progress_bar_group_round_group"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_gravity="center_vertical"
         app:bootstrapSize="md"
         app:bootstrapMaxProgress="100">

         <com.beardedhen.androidbootstrap.BootstrapProgressBar
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             app:bootstrapBrand="success"
             app:bootstrapProgress="20"
             />

         <com.beardedhen.androidbootstrap.BootstrapProgressBar
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             app:bootstrapBrand="danger"
             app:bootstrapProgress="20"
             />

         </com.beardedhen.androidbootstrap.BootstrapProgressBarGroup>

BootstrapProgressBarGroup

7BootstrapLabel

It displays non-clickable text in a widget similar to the BootstrapButton, sizable using H1-H6 elements.

<com.beardedhen.androidbootstrap.BootstrapLabel
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 app:bootstrapBrand="primary"
 app:bootstrapHeading="h3"
 app:roundedCorners="true"
 android:text="Bootstrap Label"
 />

BootstrapLabel

Recommended article : Multicolor TextView in Android?

8BootstrapEditText

It allows editing of text in a widget themed using BootstrapBrand.

<com.beardedhen.androidbootstrap.BootstrapEditText
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 app:bootstrapSize="md"
 app:bootstrapBrand="info"
 />

BootstrapEditText

9BootstrapCircleThumbnail

It displays images in a center-cropped Circular View, themed with BootstrapBrand.

<com.beardedhen.androidbootstrap.BootstrapCircleThumbnail
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src="@drawable/my_drawable"
 app:bootstrapBrand="danger"
 app:hasBorder="true"
 />

BootstrapCircleThumbnail

10BootstrapThumbnail

It displays images in a rectangular View, themed with BootstrapBrand.

<com.beardedhen.androidbootstrap.BootstrapThumbnail
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:src="@drawable/my_drawable"
 app:bootstrapBrand="info"
 app:hasBorder="true"
 />

BootstrapThumbnail

11BootstrapWell

It displays a view in a themed container.

<com.beardedhen.androidbootstrap.BootstrapWell
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="8dp"
        app:bootstrapSize="xl">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="Look, I'm in a large well!"
            />
    </com.beardedhen.androidbootstrap.BootstrapWell>

BootstrapWell

12BootstrapDropDown

It displays a view with dropdown options, supplied by an array of strings.

<com.beardedhen.androidbootstrap.BootstrapDropDown
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                app:bootstrapText="Medium {fa_thumbs_o_up}"
                app:bootstrapBrand="regular"
                app:roundedCorners="true"
                app:bootstrapSize="md"
                app:dropdownResource="@array/bootstrap_dropdown_example_data"
                app:bootstrapExpandDirection="down"/>

BootstrapDropdown

13Custom Styles

Custom styles can be applied to any of the views in this library by creating a class which implements BootstrapBrand, and setting it on the View. Please see the sample code of BootstrapButton for more detail.

class CustomBootstrapStyle implements BootstrapBrand {
        // specify desired colors here
    }

    BootstrapButton btn = new BootstrapButton(context);
    btn.setBootstrapBrand(new CustomBootstrapStyle(this);

Hope you enjoy this tutorial and want to add this helping library in your project. If you want and if got some problem then comment us.

You can comment or suggestion also in comment. Happy coding!!!

Share your thoughts

Loading Facebook Comments ...
Loading Disqus Comments ...