https://github.com/commit451/scriminsetslayout
ScrimInsetsFrameLayout from the design support library
https://github.com/commit451/scriminsetslayout
android framelayout insets scrim
Last synced: 6 months ago
JSON representation
ScrimInsetsFrameLayout from the design support library
- Host: GitHub
- URL: https://github.com/commit451/scriminsetslayout
- Owner: Commit451
- License: apache-2.0
- Created: 2017-01-10T22:35:34.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2022-06-27T04:29:09.000Z (over 3 years ago)
- Last Synced: 2025-04-26T02:52:34.569Z (8 months ago)
- Topics: android, framelayout, insets, scrim
- Language: Java
- Size: 1.72 MB
- Stars: 52
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ScrimInsetsLayout
ScrimInsetsFrameLayout from the design support library
[](https://travis-ci.org/Commit451/ScrimInsetsLayout) [](https://jitpack.io/#Commit451/ScrimInsetsLayout)

# Usage
If you want to do the typical thing where a view is pushed below the status bar:
First, you need to modify the style of the activity:
```xml
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>
```
Then, within your activity:
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
setContentView(R.layout.activity_main);
//All the content you want to be below the status bar
final ViewGroup rootContent = (ViewGroup) findViewById(R.id.root_content);
ScrimInsetsFrameLayout scrimInsetsFrameLayout = (ScrimInsetsFrameLayout) findViewById(R.id.root_insets);
scrimInsetsFrameLayout.setOnInsetsCallback(new OnInsetsCallback() {
@Override
public void onInsetsChanged(Rect insets) {
rootContent.setPadding(0, insets.top, 0, 0);
}
});
}
```
See the `app` module for more examples. Note that though this library has a minSdk of 15, the insets will only apply on API 21+.
License
--------
Copyright 2019 Commit 451
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.