Skip to content

一个完全无侵入、简单易用的处理 WindowInsets 的库。

License

Notifications You must be signed in to change notification settings

liu-wanshun/Insetter

Repository files navigation

Insetter

GitHub license

一个完全无侵入、简单易用的处理 WindowInsets 的库。

Gradle添加依赖

  1. 引入jitpack仓库
repositories {
    maven {
        name = "jitpack"
        url = uri("https://jitpack.io")
    }
}
  1. 添加依赖最新版 (将Tag替换为 后面的数字)
dependencies {
    implementation("com.github.liu-wanshun:Insetter:Tag")
}

用法

  1. 在布局文件中添加以下属性即可,无需任何代码。 这些属性完全来自于Material组件库 ,所以这个Insetter库可以做到完全无侵入。
  • app:paddingLeftSystemWindowInsets: 将system window insets 的 left 应用于视图的paddingLeft.
  • app:paddingTopSystemWindowInsets :将system window insets 的 top 应用于视图的paddingTop.
  • app:paddingRightSystemWindowInsets: 将system window insets 的 right 应用于视图的paddingRight.
  • app:paddingBottomSystemWindowInsets :将system window insets 的 bottom 应用于视图的paddingBottom.

例如:

<FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" app:paddingBottomSystemWindowInsets="true">

    <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_gravity="center" android:text="Button" />

</FrameLayout>
  1. 如果不生效,请在加载布局前,也就是调用inflate方法之前调用inject方法
Insetter.inject(context)

更新日志

Releases

感谢

License

Copyright (C) 2022. liuwanshun

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.

About

一个完全无侵入、简单易用的处理 WindowInsets 的库。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages