Ramotion / cardslider-android

:octocat: 🃏 Cardslider is a material design UI controller that allows you to swipe through cards with pictures and accompanying descriptions.
https://www.ramotion.com/cardslider-android-ui-app-development-library-to-interact-with-cards/
MIT License
2.34k stars 358 forks source link

How to place the card a little bit to the left? #31

Closed ianeinser closed 5 years ago

ianeinser commented 5 years ago

Hi,

i tried to set the parameter recycler_view_left_offset in dimens.xml and DEFAULT_ACTIVE_CARD_LEFT_OFFSET in CardSliderLayoutManager but it doesn't work. I appreciate if you can share the tip.

golovin47 commented 5 years ago

Hello, @ianeinser. Readme of this lib tells you everything you need. Here are the attributes you can specify in the constructor or XML layout: activeCardLeft - Active card offset from start of RecyclerView. Default value is 50dp. cardWidth - Card width. Default value is 148dp. cardsGap - Distance between cards. Default value is 12dp.

Example:

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="210dp"
    android:layout_marginStart="@dimen/recycler_view_left_offset"
    android:layout_marginTop="18dp"
    android:clipChildren="false"
    android:overScrollMode="never"
    app:activeCardLeftOffset="150dp"
    app:layoutManager="com.ramotion.cardslider.CardSliderLayoutManager"
    app:viewUpdater="com.ramotion.cardslider.examples.simple.cards.CardsUpdater" />

If you need some other behavior, you may fork this lib and apply any changes you want.

ianeinser commented 5 years ago

Hey @golovin47 ,

Thanks a lot. app:activeCardLeftOffset="150dp" does the job! thanks

ianeinser commented 5 years ago

Hi @golovin47 ,

it is me again... i tried to set app:activeCardLeftOffset="20dp" but the active card covers the card behind completely. How to place the covered card a little bit left (not the active card)?

golovin47 commented 5 years ago

Left offset is being calculated by many params. If you need to customize it, you'll have to fork the lib and change CardSliderLayoutManager.