Skip to content

Commit

Permalink
refactor: Use ConstrainedWidth to enforce WRAP_CONTENT constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushiknsanji committed Oct 19, 2019
1 parent 2ecd3a6 commit da3ef41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/src/main/res/layout/books_grid_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
<TextView
android:id="@+id/grid_item_title_text_id"
style="@style/BookTileTitleStyle"
android:layout_width="wrap_content"
android:textAlignment="center"
android:gravity="center"
tools:text="Grief is the Thing with Feathers" />

<RatingBar
Expand Down Expand Up @@ -97,6 +96,7 @@
style="@style/ConstraintCenterHorizontalStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
android:layout_marginTop="@dimen/grid_item_content_row_margin_top"
android:ellipsize="end"
android:maxLines="1"
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/layout/books_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
<TextView
android:id="@+id/list_item_title_text_id"
style="@style/BookTileTitleStyle"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
app:layout_constraintHorizontal_bias="0"
tools:text="Grief is the Thing with Feathers" />

<RatingBar
Expand Down Expand Up @@ -200,8 +201,10 @@
<TextView
android:id="@+id/list_item_categories_text_id"
style="@style/ConstraintCenterHorizontalStyle"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:layout_marginTop="@dimen/list_item_categories_text_margin_top"
android:drawableLeft="@drawable/ic_library"
android:drawablePadding="@dimen/list_item_drawable_padding"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,12 @@
<!-- Parent Style for the Book Titles that appear in the List/Grid -->
<style name="BookTileTitleStyle" parent="ConstraintTopCenterHorizontalStyle">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:ellipsize">end</item>
<item name="android:maxLines">2</item>
<item name="android:textSize">@dimen/list_grid_item_title_text_size</item>
<item name="layout_constrainedWidth">true</item>
</style>

<!-- Style for the List Price Text appearing the Book Tile of List/Grid views -->
Expand Down

0 comments on commit da3ef41

Please sign in to comment.