腾讯Android原生UI框架---QMUI

QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目,同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。

功能特性大致如下:

大致解读一下,就是功能有三大特性:

  1. 可以全局配置 UI 样式,一处修改,全局生效,超级方便。
  2. 提供了丰富的 UI 控件库,各种动画,列表,Button,底部菜单,下拉刷新,各种 Tab,弹框等等,以后直接可以使用,不用自己动手写了。
  3. 提供了高效的工具,可以获取屏幕信息,键盘管理,状态栏管理,状态栏沉浸等等。以前我们是从网上找各种工具类,现在腾讯帮你弄在一起了,还不错。

Demo 截图如下:

开源项目地址:https://github.com/Tencent/QMUI_Android

官网:http://qmuiteam.com/android

要在 Android 项目中使用 QMUI Android,可以按照以下步骤进行: 1. 将 QMUI Android 引入项目中,可以使用 Gradle,将以下代码添加到 `build.gradle` 文件中: ```groovy dependencies { implementation 'com.qmuiteam:qmui:2.1.0' } ``` 2. 在 Application 类中初始化 QMUI,可以在 `onCreate()` 方法中添加以下代码: ```java public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); QMUI.init(this); } } ``` 3. 在布局文件中使用 QMUI 的控件,例如: ```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:qmui="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.qmuiteam.qmui.widget.QMUITopBarLayout android:id="@+id/topbar" qmui:layout_constraintTop_toTopOf="parent" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"/> <com.qmuiteam.qmui.widget.QMUIRoundButton android:id="@+id/button" android:text="Button" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> ``` 在这个例子中,我们使用了 `QMUITopBarLayout` 和 `QMUIRoundButton`,它们都是 QMUI 的控件,可以通过 `xmlns:qmui="http://schemas.android.com/apk/res-auto"` 引入 QMUI 的命名空间。 在 Activity 类中,可以通过以下方式来获取控件的实例: ```java public class MyActivity extends AppCompatActivity { private QMUITopBarLayout mTopBarLayout; private QMUIRoundButton mButton; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); mTopBarLayout = findViewById(R.id.topbar); mButton = findViewById(R.id.button); // 设置 TopBar 的标题 mTopBarLayout.setTitle("My Activity"); } } ``` 以上就是使用 QMUI Android 的基本步骤,更多的 QMUI 控件和用法可以参考官方文档。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值