Reputation: 153
I am trying to set left and right padding of the text block using constraint layout guidelines. I want 11% padding with the following code on both sides. However, when I try to set the paddings it is not reflecting. When I only use either left or right then it is showing, but using both left and right guidelines on text view the padding is not reflecting.
Here is the code
<android.support.constraint.ConstraintLayout
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/centredIconLayout"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:fontFamily="@font/gothamggm_bold"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:text="@string/title_long"
android:textSize="17sp"
android:lineSpacingExtra="9sp"
android:textColor="@android:color/black"
app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
app:layout_constraintRight_toLeftOf="@+id/right_guideline"
/>
<TextView
android:id="@+id/body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="13dp"
android:fontFamily="@font/gothamssm_book"
android:lineSpacingExtra="9sp"
android:text="@string/content_large"
android:textColor="@color/body_grey"
android:textSize="12sp"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
app:layout_constraintRight_toLeftOf="@+id/right_guideline"
/>
<android.support.constraint.Guideline
android:id="@+id/left_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.11" />
<android.support.constraint.Guideline
android:id="@+id/right_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.89" />
</android.support.constraint.ConstraintLayout>
Here is the blue print where both text views (included in @+id/contentLayout) are below image view
Upvotes: 1
Views: 1163
Reputation: 2607
The problem is in width of textview. You have set it to wrap_content
. This is creating the problem. just change it to match_constraints
in layout editor or set width to 0dp
in xml code manually and all will work fine.
Upvotes: 1