Android Studio 引入Xui框架-简单应用

Android Studio Flamingo | 2022.2.1 Patch 2 

Android 11开发、Gradle Version 8.0、 jdk17

源代码:GitHub - xuexiangjys/XUI: 💍A simple and elegant Android native UI framework, free your hands! (一个简洁而优雅的Android原生UI框架,解放你的双手!)

参考手册:

Home · xuexiangjys/XUI Wiki · GitHub

快速继承Demo:

GitHub - xuexiangjys/TemplateAppProject: Android template project, fast construction (integrated XUI, XUtil, XAOP, XPage, XUpdate, XHttp2, Umeng Statistics and Walle multi-channel package). Android空壳模板工程,快速搭建(集成了XUI、XUtil、XAOP、XPage、XUpdate、XHttp2、友盟统计和walle多渠道打包)

1.在settings.gradle文件中加入依赖   maven { url "https://jitpack.io" }  

(点击 Sync Now 同步下)

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        //导入maven
        maven { url "https://jitpack.io" }
    }
}

2.在build.gradle 引入Xui   implementation 'com.github.xuexiangjys:XUI:1.1.5'

(点击 Sync Now 同步下)

dependencies {

    //xui
    implementation 'com.github.xuexiangjys:XUI:1.1.5'

    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

3. 写个类继承 Application 重写onCreate方法 加入

         XUI.init(this); //初始化UI框架
        XUI.debug(true);  //开启UI框架调试日志

import android.app.Application;

import com.xuexiang.xui.XUI;

public class XuiActivity extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        XUI.init(this); //初始化UI框架
        XUI.debug(true);  //开启UI框架调试日志
    }
}

4.在AndroidManifest.xml中加入 这个类  android:name=".XuiActivity"

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

    <application
          <!-- 加入-->
        android:name=".XuiActivity"

        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/Theme.MyAppday3">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

5.把样式改一下

基础主题类型:

大平板(10英寸, 240dpi, 1920*1200):XUITheme.Tablet.Big


小平板(7英寸, 320dpi, 1920*1200):XUITheme.Tablet.Small


手机(4.5英寸, 320dpi, 720*1280):XUITheme.Phone


<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Base.Theme.MyAppday3" parent="XUITheme.Phone">
        <!-- Customize your light theme here. -->
        <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
    </style>

    <style name="Theme.MyAppday3" parent="Base.Theme.MyAppday3" />
</resources>

6.即可在布局中添加相关组件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center"
        >
    <com.xuexiang.xui.widget.button.roundbutton.RoundButton
        style="@style/RoundButton.Auto"
        android:layout_marginTop="20dp"
        android:text="默认圆角大小" />

    <com.xuexiang.xui.widget.button.roundbutton.RoundButton
        style="@style/RoundButton.Auto"
        android:layout_marginTop="20dp"
        android:text="自定义样式"
        android:textColor="@color/xui_default_round_btn_white_text"
        app:rb_backgroundColor="@color/xui_round_btn_green_bg"
        app:rb_borderColor="@color/xui_round_btn_green_bg" />

    <com.xuexiang.xui.widget.button.shadowbutton.ShadowButton
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_margin="16dp"
        app:sb_ripple_duration="2000"
        android:background="@mipmap/ic_launcher"
        app:sb_ripple_color="@color/app_color_theme_8"
        app:sb_color_pressed="@color/app_color_theme_6"
        app:sb_radius="6dp" />



    <com.xuexiang.xui.widget.button.ButtonView
        style="@style/ButtonView.Blue"
        android:layout_margin="20dp"/>

    <com.xuexiang.xui.widget.button.ButtonView
        style="@style/ButtonView.Green"
        android:layout_margin="20dp"/>

    <com.xuexiang.xui.widget.button.ButtonView
        style="@style/ButtonView.Gray"
        android:layout_margin="20dp"/>
<!-- 倒计时button-->
        <com.xuexiang.xui.widget.button.CountDownButton
            android:id="@+id/bt_countdown4"
            style="@style/Button.Blue"
            android:text="获取验证码" />

        <com.xuexiang.xui.widget.button.switchbutton.SwitchButton
            android:id="@+id/sb_ios"
            style="@style/SwitchButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:swb_animationDuration="300"
            app:swb_backDrawable="@drawable/ios_back_drawable"
            app:swb_thumbDrawable="@drawable/ios_thumb_selector"
            app:swb_thumbMarginBottom="-8dp"
            app:swb_thumbMarginLeft="-5dp"
            app:swb_thumbMarginRight="-5dp"
            app:swb_thumbMarginTop="-2.5dp"
            app:swb_thumbRangeRatio="1.4" />


        <com.xuexiang.xui.widget.button.RippleView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="?attr/xui_config_content_spacing_horizontal"
            app:rv_type="simpleRipple">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_gravity="center"
                android:layout_marginStart="?attr/xui_config_content_spacing_horizontal"
                android:layout_marginEnd="?attr/xui_config_content_spacing_horizontal"
                android:background="@color/app_color_theme_1"
                android:gravity="center"
                android:text="单波纹"
                android:textColor="@color/xui_config_color_white"
                android:textSize="20sp" />

        </com.xuexiang.xui.widget.button.RippleView>

        <!-- 悬浮按钮-->
        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:layout_width="50dp"
            android:layout_height="50dp"
            app:borderWidth="10px"
            android:backgroundTint="@color/app_color_theme_4"
            app:rippleColor="@color/app_color_theme_3"
            />


        <com.xuexiang.xui.widget.button.SwitchIconView
            android:id="@+id/switchIconView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:padding="8dp"
            app:siv_disabled_alpha=".5"
            app:siv_disabled_color="#dadada"
            app:siv_enabled="true"
            app:siv_tint_color="#ffb700"

            app:srcCompat="@drawable/ic_camera" />



        <com.xuexiang.xui.widget.button.SmoothCheckBox
            android:id="@+id/scb"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:paddingTop="10dp"
            app:scb_color_checked="@color/app_color_theme_1" />


        <com.xuexiang.xui.widget.button.shinebutton.ShineButton
            android:id="@+id/shine_button"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="center"
            app:sb_checked_color="#f26d7d"
            app:sb_icon_image="@drawable/ic_heart"
            app:sb_normal_color="@android:color/darker_gray" />

        <com.xuexiang.xui.widget.button.shinebutton.ShineButton
            android:id="@+id/shine_button_1"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="center"
            android:src="@android:color/darker_gray"
            app:sb_allow_random_color="false"
            app:sb_big_shine_color="#FF6666"
            app:sb_checked_color="#FF6666"
            app:sb_click_animation_duration="200"
            app:sb_enable_flashing="false"
            app:sb_icon_image="@drawable/ic_like"
            app:sb_normal_color="@android:color/darker_gray"
            app:sb_shine_animation_duration="1500"
            app:sb_shine_count="15"
            app:sb_shine_distance_multiple="1.5"
            app:sb_shine_turn_angle="10"
            app:sb_small_shine_color="#CC9999"
            app:sb_small_shine_offset_angle="20" />


    <!-- button xui-->
    <com.xuexiang.xui.widget.button.ButtonView
        android:id="@+id/buttonView"
        style="@style/ButtonView.Green"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginTop="237dp"
        android:layout_marginBottom="69dp"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />




    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

         </LinearLayout>

    </ScrollView>
</LinearLayout>

实例图: 

相关资源:导入项目后,在源项目码中查找 Ctrl+N 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/172049.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

python tkinter 使用

python tkinter 使用 ython可以使用多种GUI库来创建窗口页面&#xff0c;例如Tkinter、PyQt、wxPython等。 本篇文章主要讲述如何使用tkinter。 1&#xff1a;导入 import tkinter as tk这时如果运行的话会提示&#xff1a; ModuleNotFoundError: No module named ‘tkint…

卷?中学生开始学习人工智能和大模型,附课件!

卷&#xff1f;中学生开始学习人工智能和大模型&#xff0c;附课件&#xff01; 大家好&#xff0c;我是老章 发现一个面向11-14岁人群的AI课程&#xff0c;还附加了大模型内容&#xff0c;浏览了一遍它们的课件&#xff08;还有面向教师的资源&#xff09;&#xff0c;感觉非…

SAP 重复制造简介

重复制造是制造模块三大制造模式&#xff08;离散、流程、重复&#xff09;之一&#xff0c;是专门用于产品大批量输出的生产环境。 重复制造与JIT管理思想、拉式生产理念紧密结合&#xff0c;首先在日本企业中得到广泛且成功的运用。与重复制造密切相关的功能&#xff0c;如看…

【力扣】 209. 长度最小的子数组

【力扣】 209. 长度最小的子数组 文章目录 【力扣】 209. 长度最小的子数组1. 题目介绍2. 解法2.1 暴力求解2.2 前缀和 二分查找2.3 滑动窗口2.4 贪心回溯 3. Danger参考 1. 题目介绍 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 …

负载均衡Ribbon和Feign的使用与区别

Ribbon 的介绍 Spring Cloud Ribbon 是基于Netflix Ribbon 实现的一套客户端负载均衡的工具。主要功能是提供客户端的软件负载均衡和服务调用。Ribbon 客户端组件提供一系列完善的配置项如连接超时&#xff0c;重试等。简单的说&#xff0c;就是在配置文件中列出Load Balancer…

“茶叶创新:爆改营销策略,三个月狂销2300万“

我的朋友去年制作了一款白茶&#xff0c;并在短短三个月内将其销售量推到了2300万的高峰。你相信吗&#xff1f; 这位朋友并没有任何茶叶方面的经验&#xff0c;他只是一个有着冒险精神的企业家。他先找到了一家代工厂&#xff0c;帮助他把他的茶叶理念转化为现实。 当他把茶叶…

小趴菜教你如何用Python开发手机App..

Python语言虽然很万能&#xff0c;但用它来开发app还是显得有点不对路&#xff0c;因此用Python开发的app应当是作为编码练习、或者自娱自乐所用&#xff0c;加上目前这方面的模块还不是特别成熟&#xff0c;bug比较多&#xff0c;总而言之&#xff0c;劝君莫轻入。 准备工作 …

Java修仙记之记录一次与前端女修士论道的经历

文章开始之前&#xff0c;想跟我念一句&#xff1a;福生无量天尊&#xff0c;无量寿佛&#xff0c;阿弥陀佛 第一场论道&#xff1a;id更新之争 一个天气明朗的下午&#xff0c;前端的小美女长发姐告诉我&#xff1a;嘿&#xff0c;小后端&#xff0c;你的代码报错了 我答道&am…

【旅游行业】Axure旅游社交平台APP端原型图,攻略门票酒店民宿原型案例

作品概况 页面数量&#xff1a;共 110 页 兼容软件&#xff1a;Axure RP 9/10&#xff0c;不支持低版本 应用领域&#xff1a;旅游平台&#xff0c;酒店住宿 作品申明&#xff1a;页面内容仅用于功能演示&#xff0c;无实际功能 作品特色 本作品为「旅游社交平台」移动端…

每日一练 | 华为认证真题练习Day134

1、开启标准STP协议的交换机可能存在哪些端口状态&#xff1f;&#xff08;多选&#xff09; A. Discarding B. Listening C. Disabled D. Forwarding 2、下列路由协议中优先级最高的是&#xff1f; A. Direct B. RIP C. OSPF D. Static 3、参考如图所示的输出结果&…

如何使用API接口对接淘宝获取店铺销量排序,店铺名称等参数

要接入淘宝官方开放平台API接口获取店铺销量排序&#xff0c;店铺名称等参数&#xff0c;需要按照以下步骤进行操作&#xff1a; 找到可用的API接口&#xff1a;首先&#xff0c;需要找到支持查询店铺信息的API接口。可以在电商数据平台的开放平台上查找相应的API接口。注册并…

PHP 进阶之路 - 亿级 pv 网站架构实战之性能优化

PHP 进阶之路 - 亿级 pv 网站架构实战之性能优化 缘起 PV和PU&#xff08;数据分析—业务指标&#xff09; PV即访问次数——用户每访问一次可以看作一次PV。 PU即访问人数——在同一天内&#xff0c;一个用户无论访问了多少次都算一个访客。 通过PV和PU可以分析出用户喜欢…

【无公网IP内网穿透】异地远程访问本地SQL Server数据库

目录 1.前言 2.本地安装和设置SQL Server 2.1 SQL Server下载 2.2 SQL Server本地连接测试 2.3 Cpolar内网穿透的下载和安装 2.3 Cpolar内网穿透的注册 3.本地网页发布 3.1 Cpolar云端设置 3.2 Cpolar本地设置 4.公网访问测试 5.结语 1.前言 数据库的重要性相信大家…

智慧安防监控系统EasyCVR(v3.4)开放协议的介绍及使用

安防视频监控系统EasyCVR平台可拓展性强、视频能力灵活、部署轻快&#xff0c;可支持的主流标准协议有国标GB28181、RTSP/Onvif、RTMP等&#xff0c;以及支持厂家私有协议与SDK接入&#xff0c;包括海康Ehome、海大宇等设备的SDK等。平台可拓展性强、视频能力灵活&#xff0c;能…

MS90C386:+3.3V 175MHz 的 24bit 平板显示器(FPD)LVDS 信号接收器

产品简述 MS90C386 芯片能够将 4 通道的低压差分信号&#xff08; LVDS &#xff09;转换成 28bit 的 TTL 数据。时钟通道与数据通道并行输入。在时钟频率 为 175MHz 时&#xff0c; 24bit 的 RGB 数据、 3bit 的 LCD 时序数据和 1bit 的控制数据以 1225Mb…

electron桌面应用webSoket实时弹框提示实现

一、实现效果&#xff1a;网页端或者移动端进行了审核操作&#xff0c;在电脑右下角提示用户查看。 1、当有弹框提示的情况时&#xff0c;会弹出如下提示&#xff0c;点击查看自动跳转到当前地址&#xff0c;点击关闭则关闭当前提示窗口&#xff1b; 2、当有两条及其以上的消息…

redis--高可用之持久化

redis高可用相关知识 在web服务器中&#xff0c;高可用是指服务器可以正常访问的时间&#xff0c;衡量的标准是在多长时间内可以提供正常服务(99.9%、99.99%、99.999%等等)。 但是在Redis语境中&#xff0c;高可用的含义似乎要宽泛一些&#xff0c;除了保证提供正常服务( 如主…

前端css粘性布局,顶部吸附效果(position: sticky)

sticky属性设置 /* 设置粘性布局 */ position: sticky; /* 拖动滚动条&#xff0c;当前元素超出文档0的位置时&#xff0c;触发定位效果&#xff08;同级元素位置不会受影响&#xff09; */ top: 0;页面初始效果 设置前&#xff08;滚动页面时&#xff0c;标签栏随页面滚动&a…

数字电路的基础知识

一、数字电路概述 用数字信号完成对数字量进行逻辑运算和算术运算的电路称为数字电路。 由于它具有逻辑运算和逻辑处理功能&#xff0c;所以又称为数字逻辑电路。 现代的数字电路由半导体工艺制成的数字集成器件构造而成。 逻辑门是数字电路的基本单元电路&#xff0c;就如同在…

海康威视监控相机的SDK与opencv调用(非工业相机)

1.研究内容 本篇主要对海康威视的监控相机的SDK回调进行研究&#xff0c;并于opencv结合&#xff0c;保存图像,以供后续其他处理&#xff0c;开发语言为C 2.步骤及方法 2.1 海康SDK介绍 海康SDK下载地址 根据自身编译环境&#xff0c;下载对应的SDK&#xff0c;需要注意的是…
最新文章