安卓平台下使用bootstrap
来源:互联网 发布:廉价口红知乎 编辑:程序博客网 时间:2024/06/14 10:39
之前在web下已经习惯了使用bootstrap,轻易就可以调出不错的样式,后来发现原来安卓平台下也可以用bootstrap,所以用bootstrap写了一个小demo
首先需要引入依赖包
dependencies { compile 'com.beardedhen:androidbootstrap:2.0.1'}
然后需要覆盖application类,bootstrap需要通过这个类注册icon
public class SampleApplication extends Application{ private static Application instance; public static Application getAplication(){ return instance; } public static Context getContext(){ return instance.getApplicationContext(); } @Override public void onCreate() { super.onCreate(); instance=this; TypefaceProvider.registerDefaultIconSets(); }}
然后就可以开始使用bootstrap了,用法和web端很类似。详细的请看文档https://github.com/Bearded-Hen/Android-Bootstrap/wiki/Awesome-Text-View
下面是用bootstrap写的登录界面
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="layout.LoginFragment"> <com.beardedhen.androidbootstrap.BootstrapEditText android:layout_width="200dp" android:layout_height="40dp" app:bootstrapSize="xl" app:bootstrapBrand="success" app:roundedCorners="true" android:textSize="15sp" android:cursorVisible="false" android:gravity="center" android:id="@+id/username" android:layout_alignParentTop="true" android:layout_alignLeft="@+id/password" android:layout_alignStart="@+id/password" android:layout_marginTop="49dp" /> <com.beardedhen.androidbootstrap.BootstrapButton android:layout_width="200dp" android:layout_height="wrap_content" android:onClick="login" app:bootstrapBrand="success" app:bootstrapSize="lg" app:buttonMode="regular" app:showOutline="false" app:roundedCorners="true" app:bootstrapText="{fa_user} 登录 " android:id="@+id/login" android:layout_centerVertical="true" android:layout_alignLeft="@+id/register" android:layout_alignStart="@+id/register" /> <com.beardedhen.androidbootstrap.BootstrapButton android:layout_width="200dp" android:layout_height="wrap_content" android:text="@string/register" android:onClick="register" app:bootstrapText="{fa_lock} 注册 " app:bootstrapBrand="primary" app:bootstrapSize="lg" app:buttonMode="regular" app:showOutline="false" app:roundedCorners="true" android:id="@+id/register" android:layout_below="@+id/login" android:layout_centerHorizontal="true" android:layout_marginTop="44dp" /> <com.beardedhen.androidbootstrap.BootstrapEditText android:layout_width="200dp" android:layout_height="40dp" app:bootstrapSize="xl" app:bootstrapBrand="success" app:roundedCorners="true" android:textSize="15sp" android:cursorVisible="false" android:gravity="center" android:id="@+id/password" android:layout_marginTop="49dp" android:layout_below="@+id/username" android:layout_alignLeft="@+id/login" android:layout_alignStart="@+id/login" /> <com.beardedhen.androidbootstrap.BootstrapLabel android:layout_width="100dp" android:layout_height="25dp" app:bootstrapBrand="success" app:bootstrapHeading="h6" app:roundedCorners="true" android:text="登录成功" android:layout_marginTop="26dp" android:id="@+id/successLabel" android:layout_below="@+id/register" android:layout_centerHorizontal="true" android:visibility="invisible"/> <com.beardedhen.androidbootstrap.BootstrapLabel android:layout_width="100dp" android:layout_height="25dp" app:bootstrapBrand="danger" app:bootstrapHeading="h6" app:roundedCorners="true" android:text="登录失败" android:layout_marginTop="26dp" android:id="@+id/failLabel" android:layout_below="@+id/register" android:layout_centerHorizontal="true" android:visibility="invisible"> </com.beardedhen.androidbootstrap.BootstrapLabel></RelativeLayout>
阅读全文
1 0
- 安卓平台下使用bootstrap
- 安卓平台使用sqlite
- 安卓平台下的即时通讯
- 安卓平台下的即时通讯
- FFTW安卓平台下编译
- Unity3d在安卓平台下使用sqlite存储操作数据
- 使用UE4发布安卓平台游戏
- 使用UE4发布安卓平台游戏
- 关于安卓平台下的音视频开发系统
- 安卓平台下的按钮效果处理
- NDK学习(5) 安卓平台下 NDK编译lua
- Appcelerator 安卓平台下emoji表情符号替换为图片
- 安卓平台下访问StreamingAssets目录下文件
- Unity中调用安卓平台下的系统按键
- android安卓开发-eclipse平台下错误记录
- 解决安卓平台下,input标签遮挡问题
- 安卓广告平台
- 安卓平台使用pocketSphinx离线语音识别
- 【DRP】ajax总结
- Myeclipse运行JMS的生产者时,报错:“java.lang.UnsupportedClassVersionError : Unsupported major.minor version 51”
- 自定义view 自定义进度条 progress
- 写个准备读研的学弟的Java学习指南
- dubbo-admin管理平台搭建简单介绍
- 安卓平台下使用bootstrap
- Android TextUtils类介绍
- 【linq】-实现数据的随机查询
- Unity编辑脚本(启动指南)-脚本对象
- handler原理分析及模仿handler实现简单主/子线程通信架构
- c++---不使用“+”实现加法操作
- 开始
- acm基础--括号配对问题
- Spring_demo6_AOP_XML