Android使用Bootstrap控件

本文介绍了如何在Android项目中使用Bootstrap控件。首先,通过添加2.3.2或2.0.1版本的Bootstrap依赖库到Module。然后,创建一个继承自Application的类,并在清单文件中配置。最后,将普通Button替换为BootstrapButton,设置样式和圆角属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一步:Moudle加入Bootstrap依赖库(目前提供版本2.3.2,如果提示不成功改成2.0.1版本)

implementation 'com.beardedhen:androidbootstrap:2.3.2'

implementation 'com.beardedhen:androidbootstrap:2.0.1'

第二步:在java包下新建一个类,在Superclass下查找Application,并继承这个类,选择android.app.Application点击确定,并添加一下代码:

import android.app.Application;

import com.beardedhen.androidbootstrap.TypefaceProvider;

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

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

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.didu.myapplication">

    <uses-permission android:name="android.permission.INTERNET" />

    <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>
        <activity android:name=".Index"></activity>
    </application>

</manifest>

第四步:layout布局文件下的.xml里添加

原Button代码:

<Button
    android:id="@+id/btn000"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

现Bootstrap代码:

app:bootstrapBrand相当于HTML里的class,接样式名"success",app:roundedCorners="true""false"是否圆角

<com.beardedhen.androidbootstrap.BootstrapButton
    app:bootstrapBrand="success"
    app:roundedCorners="true"
    android:id="@+id/btn000"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

带刀走江湖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值