Giter Club home page Giter Club logo

slay's Introduction

SLay

jitpack license

SLay (Scale Layout) 是一种直接缩放布局的屏幕适配方案。

Quick Start

  1. 配置 module 的 build.gradle。

last_version: jitpack

dependencies {
    implementation 'com.github.7hens:slay:<last_version>'
}
  1. 初始化设计稿尺寸,视图会根据这个尺寸进行缩放。
class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        // 最后的参数表示设计稿尺寸(WIDTH,HEIGHT)所使用的单位, 需要与 xml 中的尺寸单位保持一致。
        SLayDesign.get().init(this, WIDTH, HEIGHT, TypedValue.COMPLEX_UNIT_PX);
    }
}
  1. 屏幕适配,推荐在 BaseActivity 中使用。
public abstract class BaseActivity extends Activity {
    @Override
    public void setContentView(int layoutResID) {
        SLayDesign.get().adapter(this).setContentView(layoutResID);
    }

    @Override
    public void setContentView(View view) {
        SLayDesign.get().adapter(this).setContentView(view);
    }
}

除 Activity 外,SLay 还可以适配 Dialog, 浮窗等。

slay's People

Contributors

7hens avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.