yarolegovich / DiscreteScrollView

A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
5.78k stars 782 forks source link

how to set the width and height dynamically #139

Closed i91h1r closed 4 years ago

i91h1r commented 6 years ago

in xml The width and height are not fixed For example: <android.support.v7.widget.CardView android:id="@+id/root" android:layout_width="wrap_content" android:layout_height="wrap_content" app:cardElevation="0dp" android:layout_gravity="center"

<ImageView android:scaleType="centerCrop" android:id="@+id/iv_pic" android:layout_width="match_parent" android:layout_height="match_parent" />

</android.support.v7.widget.CardView>

Set the width and height in the code For example: int width = DisplayUtil.getScreenWidth(holder.itemView.getContext()) - DisplayUtil.dp2px( holder.itemView.getContext(), 105);

    Utils.setRatioWidthHeight(registerTypeOneBinding.root, width,
        inviteRegisterTypeOne.getHeight(),
        inviteRegisterTypeOne.getWidth());

That's the breakdown RecyclerViewProxy.getMeasuredChildForAdapterPosition(RecyclerViewProxy.java:52) DiscreteScrollLayoutManager.layoutView(DiscreteScrollLayoutManager.java:225) DiscreteScrollLayoutManager.layoutViews(DiscreteScrollLayoutManager.java:214) DiscreteScrollLayoutManager.fill(DiscreteScrollLayoutManager.java:192) DiscreteScrollLayoutManager.onLayoutChildren(DiscreteScrollLayoutManager.java:120)

so how to set the width and height dynamically not fixed ?

think you

yarolegovich commented 4 years ago

A duplicate of #20