Reputation: 39
Is there a simple way of limiting the width of a CardView widget? On very large screens I want to keep space blank on either sides of the cards instead of stretching the card to make it extremely wide.
Upvotes: 1
Views: 3115
Reputation: 2216
You should create alternative layout in layouts-w600dp dir, it will be used for big screens,
or you can set
android:layout_marginLeft="@dimen/my_cardview_margin"
android:layout_marginRight="@dimen/my_cardview_margin"
to your CardView
and create dimen.xml in values dir and in values-w600dp dir with
different value of my_cardview_margin
...-w600dp suffix means that it will be used when current screen width is greater or equal to 600 dp.
Upvotes: 4