I have a view
that is the same size as my screen / fragment. However, I want to add a padding on the left and right edges such that on all devices, this padding looks like its the same size. when I use:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="20dp"
android:paddingEnd="20dp">
....
The padding is not equal on all devices. On a tablet, it is much smaller than on a small phone. Is there a way maybe programmatically to set the padding as equal on all devices?
and is dp
supposed to be density-independent? Then how come, on different density devices the padding set to dp
is not always the same size visually?