<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/open_explanation_button"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/open_dialog"
app:layout_constraintEnd_toEndOf="parent"
/>
<TextView
android:id="@+id/movieRatingText"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:layout_weight="53"
android:text="Rating: R"
android:textColor="@color/white"
android:textSize="20sp"
app:autoSizeMaxTextSize="100sp"
app:autoSizeMinTextSize="12sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform"
app:layout_constraintTop_toBottomOf="@+id/inASeriesOrNoText"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
I have a button with an id of open_explanation_button
, I need to place that button to the end of the movieRatingText
. The problem is that I need the movieRatingText
to be with a width of match_parent
to make sure that it’s an autoresizable text. In a more simpler way, I need to constraint the start of the open_explanation_button
to the center of the movieRatingText
, in addition to adding some margins.
Any help?
2
Answers
You have to constraint end and start of your view, to its parent
You can create a dummy view and align that as the center point of movieRatingText. And use that to start of open_explanation_button
</androidx.constraintlayout.widget.ConstraintLayout>