In terms of leaving space around a view, you'd be looking at using a margin
(see here for the difference between padding and margin in Android layouts).
Specifically in ConstraintLayout
it would look something like:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/left_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/right_text_view"
android:layout_marginRight="16dp"
android:text="left text" />
<TextView
android:id="@+id/right_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
android:text="right text" />
</android.support.constraint.ConstraintLayout>
Note the differences between the widths of the TextViews. The right one is wrap_content
so it will vary it's size to fit it's text. The left one has width of 0dp, which in a ConstraintLayout
means "match constraints". It needs a left and right constraint in order to work out what width to be, so we've given both.
We've also added a margin to the right of the first TextView to ensure a gap between views. Alternatively we could have added the 16dp as layout_marginLeft
on the second TextView or split it 8dp each, depending on what makes most sense in the circumstances.