Skip to content

Latest commit

 

History

History
 
 

dbx

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

insetter-dbx

javadoc.io

A Data Binding extension library, providing Data Binding-specific functionality. This primarily contains binding adapters, which allow access to the helper functions from your layouts. Currently the attributes provided are:

The following attributes are useful in being able to apply the system window insets insets, to specific dimensions to views.

  • app:paddingLeftSystemWindowInsets: to apply the left dimension to the view's paddingLeft.
  • app:paddingTopSystemWindowInsets: to apply the top dimension to the view's paddingTop.
  • app:paddingRightSystemWindowInsets: to apply the right dimension to the view's paddingRight.
  • app:paddingBottomSystemWindowInsets: to apply the bottom dimension to the view's paddingBottom.
  • app:layout_marginLeftSystemWindowInsets: to apply the left dimension to the view's layout_marginLeft.
  • app:layout_marginTopSystemWindowInsets: to apply the top dimension to the view's layout_marginTop .
  • app:layout_marginRightSystemWindowInsets: to apply the right dimension to the view's layout_marginRight.
  • app:layout_marginBottomSystemWindowInsets: to apply the bottom dimension to the view's layout_marginBottom.

The following attributes are useful in being able to apply the system gesture insets insets, to specific dimensions to views.

  • app:paddingLeftSystemGestureInsets: to apply the left dimension to the view's paddingLeft.
  • app:paddingTopSystemGestureInsets: to apply the top dimension to the view's paddingTop.
  • app:paddingRightSystemGestureInsets: to apply the right dimension to the view's paddingRight.
  • app:paddingBottomSystemGestureInsets: to apply the bottom dimension to the view's paddingBottom.
  • app:layout_marginLeftSystemGestureInsets: to apply the left dimension to the view's layout_marginLeft.
  • app:layout_marginTopSystemGestureInsets: to apply the top dimension to the view's layout_marginTop .
  • app:layout_marginRightSystemGestureInsets: to apply the right dimension to the view's layout_marginRight.
  • app:layout_marginBottomSystemGestureInsets: to apply the bottom dimension to the view's layout_marginBottom.

Using the applying insets attributes

Each of the attributes takes a boolean value of whether the attribute functionality is enabled or not, like so:

<ImageView
    app:paddingBottomSystemWindowInsets="@{true}"
    app:paddingLeftSystemWindowInsets="@{true}" />

You can use any non-exclusive combination of insets and application type, such as the following which uses the bottom system window inset for padding, and the left gesture inset for margin:

<ImageView
    app:paddingBottomSystemWindowInsets="@{true}"
    app:layout_marginLeftSystemGestureInsets="@{true}" />

Compound padding/margin

You can safely set any padding or margins on the view, and the values will be maintained. For example here we're using a padding of 24dp, and also applying the system window insets left and bottom using padding:

<ImageView
    app:paddingLeftSystemWindowInsets="@{true}"
    app:paddingBottomSystemWindowInsets="@{true}"
    android:padding="24dp" />

If the bottom system window insets is defined as 48dp on the device, the final applied padding for the view will be:

Dimension Layout padding System window insets Final applied padding
Left 24dp 0dp 24dp
Top 24dp 0dp 24dp (0 + 24)
Right 24dp 0dp 24dp
Bottom 24dp 48dp 72dp (24 + 48)

The same behavior happens when using margin too.

Edge-to-edge attributes

There is currently just one edge-to-edge attribute:

  • app:layout_edgeToEdge: Set this view's system-ui visibility with the flags required to be laid out 'edge-to-edge', or not.
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_edgeToEdge="@{true}">
    
    <!-- Yadda yadda -->

</FrameLayout>

When should I use this vs the widgets library?

The behavior enabled through the widgets library is similar to that provided by the this library, but without the requirement of using data-binding. If you're already using data-binding I recommend using the dbx library and it's binding adapters, since they work with any view type.

However, if you do not use data-binding and do not wish to do so, the widgets library provides very similar functionality at the cost of having to migrate to the insetter widget types.