This sounds like a dumb question, and I'm sorry if it is, but I've searched around to get a visual representation of what they are and came up with nothing.
Here is what Android has to say about it:
WindowInsets
are immutable and may be expanded to include more inset types in the future.
http://developer.android.com/reference/android/view/WindowInsets.html
Google images autocorrect it to window inserts...
Why would anyone work with these "insets"? Do they have anything to do with the navigation bar on mobile phones with no home physical keys?
Insets are areas of your view that you should not put elements, like behind the status bar or navigation bar. Think of them like paddings for the window.
If you want to draw behind them, like putting an image to the top that should be behind a translucent status bar, you will need to consume the window insets. In some views this is as easy as putting android:fitsSystemWindows=true
, but in others you will have to override the onApplyWindowInsets
method.
Usually the window insets for phones are the size of the height of the status bar as the top, the size of the navigation bar as the bottom and 0 as left and right. But It can be different, like in watches or phones with physical buttons.
They are some kind of colored margin (used in Android Wear).
They are used to create a padding from the main content to the actual border:
There are a few examples here.
This is an image with 2 insets: Circle/Squared.
They can also be used in other views to handle especial rendering requirements, like in a ScrollView: where to put the actual scroll can be defined with an insideInset as mentioned in this question.
<ScrollView
android:id="@+id/view2"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="insideInset"
android:background="@android:color/white"
android:overScrollMode="never">
You may use onApplyWindowInsets:
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
mRound = insets.isRound();
}
to detect if wearable android device is round or square, then using that information draw appropriate application interface (with round or square background)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With