Giter Site home page Giter Site logo

dialogxstyle-snackbar's Introduction

DialogXStyle-Snackbar

此主题包适用于 DialogX 框架的 PopTip 组件,提供 Snackbar 样式(含亮、暗色)

Snackbar

使用方式

警告:此主题包需要您升级 DialogX 的版本至 0.0.35 以上的版本。

  1. 进入 build.gradle(Project) 文件,在allprojects代码快添加:

    allprojects {
        repositories {
            google()
            jcenter()
            maven{
                url 'https://jitpack.io'
            }
        }
    }
    
  2. 在 build.gradle(app) 文件引入主题资源:

    implementation 'com.github.kongzue:DialogXStyle-Snackbar:1.0.6'
    
  3. 找到 DialogX.globalStyle 设置,没有可以直接使用 MaterialStyle,如果有设置其他的主题,可使用该主题 Style 替代下边代码中的 MaterialStyle,重写 popTipSettings 即可完成设置:

    DialogX.globalStyle = new MaterialStyle(){
        @Override
        public PopTipSettings popTipSettings() {
            return new PopTipSettings() {
                @Override
                public int layout(boolean light) {
                    return light?R.layout.layout_dialogx_poptip_snackbar:R.layout.layout_dialogx_poptip_snackbar_dark;
                }
                @Override
                public ALIGN align() {
                    return ALIGN.BOTTOM;
                }
                @Override
                public int enterAnimResId(boolean light) {
                    return com.kongzue.dialogx.R.anim.anim_dialogx_default_enter;
                }
                @Override
                public int exitAnimResId(boolean light) {
                    return com.kongzue.dialogx.R.anim.anim_dialogx_default_exit;
                }
            };
        }
    };
    
  4. 运行看效果。

额外配置

你可以在项目的 res 中添加 values 文件夹,并在其中建立一个资源 xml,在其中重写一些属性值,例如:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="DialogXSnackBarStyleBottomMargin">10dp</dimen>
    <dimen name="DialogXSnackBarStyleShadow">5dp</dimen>
</resources>

DialogXSnackBarStyleBottomMargin 用于配置 SnackBar 距离屏幕底部的高度,注意,这个设置不包含非安全区(导航栏的高度)。

DialogXSnackBarStyleShadow 用于设置投影的厚度,请注意此设置不可以太大,不然导航栏会裁切阴影导致观感变差。

开源协议

DialogXStyle-Snackbar 遵循 Apache License 2.0 开源协议。

Copyright Kongzue DialogXStyle-Snackbar

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.