DzmitrySlutskiy / EpamTraining2019

28 stars 20 forks source link

Incorrect displaying items in recycler view #200

Closed AliakseiShvants closed 5 years ago

AliakseiShvants commented 5 years ago

CC: @ilya-shknaj @egorikftp https://github.com/AliakseiShvants/RunningLife/tree/fragments 1) When item in recycler view doesn't have an image, it width isn't 'match_parent' screenshot-2019-04-26_11 07 59 709 2) First time recycler displays first and second item incorrectly, but after scrolling down-up there's in normal state https://drive.google.com/file/d/1hzhBMrEqAQ4-XWCoCQDXkEqHw7aNjMyH/view?usp=sharing

ilya-shknaj commented 5 years ago

@AliakseiShvants Did you try to fix it this way https://stackoverflow.com/questions/24503760/cardview-layout-width-match-parent-does-not-match-parent-recyclerview-width?

If it will not work, please push gradle folder to git, because I can't just clone and run your project

DzmitrySlutskiy commented 5 years ago

@AliakseiShvants first of all make sure your project is compilable. I've done a lot of manipulations to fix project's issues. Here main fix of your issue!: if (viewType == ViewType.MOVE) { //return new ViewHolder(new RunMoveView(parent.getContext())); return new ViewHolder(inflater.inflate(R.layout.adapter_item_run_move, parent, FALSE)); } else { return new ViewHolder(inflater.inflate(R.layout.layout_progress, parent, FALSE)); }

Pay attention to how you are going to create your views for RecyclerView. Always do inflating and pass parent into inflate method. This parameter will help this view to measure self properly!

adapter item is pretty simple: `<com.shvants.runninglife.ui.view.RunMoveView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content">

</com.shvants.runninglife.ui.view.RunMoveView>`

Also I've found few issues, you do not save item's state, if I press to item and will scroll the expanded state will be applied to any "random" item and when I arrive back to expanded item it will be in unknown state (may be expanded may be not, depends on God, stars, Moon and so on :))

AliakseiShvants commented 5 years ago

Thanks for help!

вс, 28 апр. 2019 г. в 21:27, DzmitrySlutskiy notifications@github.com:

@AliakseiShvants https://github.com/AliakseiShvants first of all make sure your project is compilable. I've done a lot of manipulations to fix project's issues. Here main fix of your issue!: if (viewType == ViewType.MOVE) { //return new ViewHolder(new RunMoveView(parent.getContext())); return new ViewHolder(inflater.inflate(R.layout.adapter_item_run_move, parent, FALSE)); } else { return new ViewHolder(inflater.inflate(R.layout.layout_progress, parent, FALSE)); }

Pay attention to how you are going to create your views for RecyclerView. Always do inflating and pass parent into inflate method. This parameter will help this view to measure self properly!

adapter item is pretty simple: `<com.shvants.runninglife.ui.view.RunMoveView xmlns:android=" http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content">

</com.shvants.runninglife.ui.view.RunMoveView>`

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DzmitrySlutskiy/EpamTraining2019/issues/200#issuecomment-487403872, or mute the thread https://github.com/notifications/unsubscribe-auth/AE2X3EN2H55V4RBU3EIDB6LPSXUBRANCNFSM4HITSTRQ .

DzmitrySlutskiy commented 5 years ago

@AliakseiShvants please close issue if your issue resolved