Giter Club home page Giter Club logo

easybinding's Introduction

EasyBinding

关于

EasyBinding是基于Android Studio的DataBinding实现的库,主要包含fit-screenbind-view两个库。其中fit-screen巧妙的使用DataBinding的特性,只需三个文件,轻松实现Android屏幕精准适配;fit-view是将ListView、GridView、RecyclerView与DataBinding结合使用的库,让你的代码更简洁!

推荐

FitScreen autolayout适配改进版

特点

  • fit-screenbind-view都只有少数几个文件,非常轻便
  • fit-screen基于DataBinding的 @BindingAdapter功能实现,可任意修改扩展

文档

使用方法(添加依赖不是最优方式,推荐直接将文件拷贝到项目中,方便拓展)

  • Step 1:
  在项目工程的build.gradle中添加以下代码
  // 注:如果添加依赖成功,则此句不必添加,此句作用仅为当项目在被审核时,紧急需要使用时添加
   allprojects {
       repositories {
           ...
           // 如果添加依赖时,报找不到项目时(项目正在审核),可以添加此句maven地址,如果找到项目,可不必添加
           maven { url "https://dl.bintray.com/albertlii/android-maven/" }
       }
    }
  • Step 2:
dependencies {
    // 不需要全部添加,使用哪个,添加哪个依赖
   compile 'com.liyi.binding:fit-screen:1.0.4'
   compile 'com.liyi.binding:bind-view:1.0.4'
}
  • Step 3:
在项目的gradle(不是工程gradle)的android{...}中添加
  // 使用dataBinding
  dataBinding {
      enabled = true
  }

fit-screen使用时,注意!注意!注意!(本人强烈推荐直接将fit-screen中的文件直接拷贝到项目中,更加方便扩展)

  • 如果在使用gradle依赖后,一直不能找到fit-screen项目中的自定义属性,报错binding error,推荐将fit-screen中的文件拷贝到项目中(强烈推荐,更加方便项目扩展),或者导入easy-screen包则可解决!
  • 加载布局时使用DataBinding加载布局,例如在Activity中加载布局,使用DataBindingUtil.setContentView()代替setContentView(),在ListView的适配器中,自定义布局中等等,凡是使用到适配的,都要用DataBinding加载布局
  • xml布局文件要遵守DataBinding的规则

赞赏

如果你感觉 EasyBinding 帮助到了你,可以点右上角 "Star" 支持一下哦!:blush:

LICENSE

Copyright 2018 liyi

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.

easybinding's People

Contributors

albert-lii avatar

Watchers

 avatar

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.