0

I have a clickable textview with padding and ripple effect on it in a constraint layout. How can i align the textview's text right hand side with the content of the constraint? Currently, because of the padding (used for the ripple effect), the text is not aligned with the rest of content. This is similar with the baseline property

enter image description here

The layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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">

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/glEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_end="@dimen/some_margin"
        />

    <Button
        android:id="@+id/btnAction"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="@id/glEnd"
        android:background="@drawable/background_home_card_bottomright"
        android:text="@string/directions"/>

    <Button
        android:id="@+id/btnSeeAll"
        style="@style/button"
        android:text="@string/see_all"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/btnAction"
        app:layout_constraintEnd_toEndOf="@id/glEnd"/>

</androidx.constraintlayout.widget.ConstraintLayout>

The button style contains padding and the background:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/rippleColor"
    android:exitFadeDuration="@android:integer/config_shortAnimTime">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/transparent"/>
        </shape>
    </item>
</ripple>
Alex
  • 191
  • 1
  • 10

0 Answers0