I have a problem with my RecyclerView
and its child items. They do not extend through the whole android:layout_width="match_parent"
nor fill_parent
. I've tried both. The thing is, this work perfectly and with no changes, it got ruined somehow.
I am showing this in a FragmentDialog
and the child items only expand like wrap_content
when I scroll the view up and down, they are fully expanded but as soon as I click on them (I call notifyDataSetChanged()
) they shrink again.
Here is a picture of a properly filled item and below it's how they are when they load or when I notifyData. Also the StickHeaderAdapter
that I use, does not show headers until I click on one of the items (this work previously and I changed nothing on that part either).
Here is the code for the child row:
<?xml version="1.0" encoding="utf-8"?>
<carbon.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:carbon_rippleColor="@color/green"
app:carbon_rippleStyle="background">
<carbon.widget.TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/block_name"
android:padding="@dimen/block_row_padding"
android:layout_weight="1"
android:textSize="@dimen/block_row_text_size"
android:textColor="@color/black"
app:carbon_rippleColor="@color/green"
app:carbon_rippleStyle="background"/>
<RelativeLayout
android:id="@+id/download_layout"
android:layout_width="64dp"
android:layout_height="match_parent"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:visibility="gone">
<carbon.widget.ProgressBar
android:id="@+id/downloading_bar"
app:carbon_progressStyle="circular_indeterminate"
app:carbon_barWidth="5dp"
app:carbon_tint="@color/green"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:visibility="invisible"/>
<carbon.widget.TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/block_progress_download"
android:textSize="12sp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="invisible" />
</RelativeLayout>
And here is the part of the adapter code where I create ViewHolder
:
@Override
public BlockAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.block_row, parent, false);
return new ViewHolder(view);
}
This is the binding code if it helps:
@Override
public void onBindViewHolder(BlockAdapter.ViewHolder holder, int position) {
if (blockData.isDownloading()) {
holder.download_layout.setVisibility(View.VISIBLE);
holder.download_bar.setVisibility(View.VISIBLE);
if (blockData.getProgress() != null) {
holder.download_progress.setVisibility(View.VISIBLE);
holder.download_progress.setText(String.format("%d%%", blockData.getProgress()));
}
} else {
holder.download_layout.setVisibility(View.GONE);
holder.download_bar.setVisibility(View.GONE);
holder.download_progress.setVisibility(View.GONE);
}
if (selected) {
holder.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.green));
holder.block_name.setTextColor(mContext.getResources().getColor(R.color.white));
} else {
holder.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.white));
holder.block_name.setTextColor(mContext.getResources().getColor(R.color.black));
}
}
I don't know why this work in the morning and changed later...
Things I tried:
- Change
match_parent
forfill_parent
- Set
RecyclerView.LayoutParams
toLayoutParams.MATCH_PARENT
- Change width programatically
- Change createViewHolder from
..., parent, false);
to..., null);
and add Params seperatelly - Logged the width (sometimes it's like 390, when I scroll it gets to 990 and when I click back to 390)
- Setup
StickHeaders
sooner, but they are all set when they get created and header is there, it's just invisible.
ANY HELP IS APPRECIATED!