kotlin-----整合开源组件Android-Bootstrap到项目中

Android Bootstrap是一个Android库,提供根据Twitter Bootstrap规范设置样式的自定义视图 这使您可以花更多的时间在开发上,而不是试图在整个应用程序中获得一致的主题

 

有关Android-Bootstrap组件可以到Github上查看:https://github.com/Bearded-Hen/Android-Bootstrap

 

第一步:Moudle加入Bootstrap依赖库

compile 'com.beardedhen:androidbootstrap:2.3.2'    //开源UI组件

 

第二步:在java包下新建一个类,并继承Application,并添加一下代码:

//传统Java模式

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

//kotlin模式

class Boot : Application() {

    override fun onCreate() {
        super.onCreate()
        TypefaceProvider.registerDefaultIconSets()
    }

}

 

第三步:清单文件里application下添加android:name=".Boot"代码

<application
        android:name=".Boot"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

 

 

使用UI组件:

 

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.mvp.org.MainActivity">

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

        <TextView
            android:id="@+id/textTest"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Look, I'm in a large well!"
            />
    </com.beardedhen.androidbootstrap.BootstrapWell>

    <com.beardedhen.androidbootstrap.BootstrapButton
        android:id="@+id/button_Test"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="测试按钮"
        app:bootstrapBrand="warning"
        app:bootstrapSize="lg"
        app:buttonMode="regular"
        app:showOutline="false"
        app:roundedCorners="true"
        />

</LinearLayout>

 

具体组件使用方法可以看例子。

附上使用引导https://github.com/Bearded-Hen/Android-Bootstrap/wiki

 

posted @ 2020-08-05 17:15  _小小白  阅读(391)  评论(0)    收藏  举报