i have created firebase recyclerview inside nestedscrollview in fragment.it works well.but when i use updateoptions in firebase recyclerview,the recyclerview not working.
I dont know how to resolve this problem.
initially the fragment created it loaded with items from firebase.the recyclerview not work when i click the button to updateoptions
this is my firebaserecyclerview
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/fragment_bg"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:layout_marginBottom="50dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat"
android:text="Hi, Aashik"
android:textColor="#color/colorPrimary"
android:layout_marginHorizontal="20dp"
android:textSize="25dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat_bold"
android:layout_marginHorizontal="20dp"
android:text="Welcome Back"
android:textColor="#color/colorPrimary"
android:textSize="30dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:fontFamily="#font/montserrat_bold"
android:text="Category"
android:textColor="#color/colorPrimaryDark"
android:textSize="20sp" />
<Button
android:id="#+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat_bold"
android:text="Products"
android:layout_marginVertical="10dp"
android:layout_marginHorizontal="20dp"
android:textColor="#color/colorPrimaryDark"
android:textSize="20sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/productsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="100dp"
android:layoutAnimation="#anim/layoutanimation"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
and the code is
productsRef = FirebaseDatabase.getInstance().getReference().child("products");
recyclerView = (RecyclerView) root.findViewById(R.id.productsRecyclerView);
btn= (Button) root.findViewById(R.id.btn);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
FirebaseRecyclerOptions<Products> options=
new FirebaseRecyclerOptions.Builder<Products>()
.setQuery(productsRef, Products.class)
.build();
adapter = new FirebaseRecyclerAdapter<Products, ProductViewHolder>(options) {
#Override
protected void onBindViewHolder(#NonNull final ProductViewHolder holder, final int position, #NonNull final Products model) {
holder.productNameTv.setText(model.getName());
Picasso.get().load(model.getImageurl()).fit().into(holder.productImageIv);
holder.cardcontainer.setAnimation(AnimationUtils.loadAnimation(getActivity(),R.anim.cardviewanimation));
holder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), ProductDetailsActivity.class);
intent.putExtra("imageurl",model.getImageurl());
intent.putExtra("name",model.getName());
intent.putExtra("desc",model.getDesc());
intent.putExtra("mrp",model.getMrp());
intent.putExtra("availability",model.getAvailability());
intent.putExtra("pid",model.getPid());
startActivity(intent);
}
});
}
#NonNull
#Override
public ProductViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.product_items_layout, parent, false);
ProductViewHolder holder = new ProductViewHolder(view);
return holder;
}
};
recyclerView.setAdapter(adapter);
adapter.startListening();
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Query query = productsRef.orderByChild("category").equalTo(catName);
FirebaseRecyclerOptions<Products> newOptions=
new FirebaseRecyclerOptions.Builder<Products>()
.setQuery(query, Products.class)
.build();
adapter.updateOptions(newOptions);
);
recylerview layout is
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginVertical="10dp"
app:cardCornerRadius="2dp"
app:cardElevation="5dp"
android:layout_marginHorizontal="20dp"
android:id="#+id/cardcontainer"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/productImageIv"
android:layout_width="100dp"
android:layout_height="match_parent"
android:src="#drawable/ic_topsym"
android:layout_margin="10dp"
>
</ImageView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="#+id/productNameTv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20sp"
android:text="#string/welcome"
android:textColor="#color/colorBlack"
android:fontFamily="#font/arimo_bold"
android:padding="20dp">
</TextView>
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
Thank in advance.
Please use swipe to refresh component or use notifiedDatasetChanged() in your adapter
Related
I have a recyclerview whose items look like this:
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_food_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="4dp">
<LinearLayout
android:id="#+id/linear_food_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
android:orientation="horizontal"
android:padding="4dp">
<com.mikhaellopez.circleview.CircleView
android:id="#+id/food_image"
android:layout_width="80dp"
android:layout_height="80dp"
app:cv_color="#color/colorAccent" />
<LinearLayout
android:id="#+id/food_contents"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:orientation="vertical">
<TextView
android:id="#+id/food_title_homepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:fontFamily="#font/sans_regular"
android:text="عنوان غذا"
android:textAppearance="#style/TextAppearance.AppCompat.Title" />
<TextView
android:id="#+id/ingredients_homepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:fontFamily="#font/sans_regular"
android:text="مواد اولیه"
android:textAppearance="#style/TextAppearance.MaterialComponents.Subtitle1" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
I'm trying to convert this into a flat hierarchy using Constraintlayout.
Here's how it looks:
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_food_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="4dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/linear_food_item"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/food_title_homepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="8dp"
android:text="عنوان غذا"
android:textAppearance="#style/TextAppearance.AppCompat.Title"
app:layout_constraintStart_toEndOf="#+id/food_image"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/ingredients_homepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="مواد اولیه"
android:textAppearance="#style/TextAppearance.MaterialComponents.Subtitle1"
app:layout_constraintStart_toEndOf="#+id/food_image"
app:layout_constraintTop_toBottomOf="#+id/food_title_homepage" />
<com.mikhaellopez.circleview.CircleView
android:id="#+id/food_image"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
app:cv_color="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Here's where my Recyclerview is inserted:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".main.homepage.HomepageFragment">
<ProgressBar
android:id="#+id/homepage_progressbar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recipes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/homepage_toolbar"
tools:listitem="#layout/fragment_homepage_food_item" />
<include
android:id="#+id/homepage_toolbar"
layout="#layout/fragment_homepage_toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Here's how each item should be: https://i.stack.imgur.com/AcfAm.png
But I don't get the same results in the Recyclerview: https://i.stack.imgur.com/jpUG4.png
I didn't have the problem before I converted the view into Constraintlayout!! Everything was working just fine until now that I converted them. They all become left-aligned in the Recyclerview!!
Does anyone know what the problem is?? Thanks in advance
-- Updated --
How it looks like on an android emulator or any other devices: https://i.stack.imgur.com/tvGz4.png
When I scroll down to the bottom (I update the list after each scroll) some items become right-aligned (they somehow get fixed) but the rest stays the same (still left aligned)
-- Java Code --
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
viewModel = new ViewModelProvider(this).get(HomepageViewModel.class);
getData(0);
setRecyclerView(linearLayoutManager);
EndlessRecyclerViewScrollListener scrollListener = new EndlessRecyclerViewScrollListener(linearLayoutManager) {
#Override
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
getData(page);
}
};
recyclerView.addOnScrollListener(scrollListener);
private void getData(int offset) {
viewModel.init(this, offset);
viewModel.getFoodsLiveData().observe(getViewLifecycleOwner(), foodList -> {
if (foodList != null) {
foods.addAll(foodList);
foodList.clear();
foodAdapter.notifyDataSetChanged();
}
});
}
private void setRecyclerView(LinearLayoutManager linearLayoutManager) {
foodAdapter = new FoodAdapter(foods);
recyclerView.setAdapter(foodAdapter);
recyclerView.setLayoutManager(linearLayoutManager);
}
My adapter:
private void getData(int offset) {
viewModel.init(this, offset);
viewModel.getFoodsLiveData().observe(getViewLifecycleOwner(), foodList -> {
if (foodList != null) {
foods.addAll(foodList);
foodList.clear();
foodAdapter.notifyDataSetChanged();
}
});
}
private void setRecyclerView(LinearLayoutManager linearLayoutManager) {
foodAdapter = new FoodAdapter(foods);
recyclerView.setAdapter(foodAdapter);
recyclerView.setLayoutManager(linearLayoutManager);
}
My adapter:
private List<Food> foods;
FoodAdapter(List<Food> foods) {
this.foods = foods;
}
static class FoodViewHolder extends RecyclerView.ViewHolder {
CircleView foodImage;
TextView foodTitle, ingredients;
CardView foodItem;
FoodViewHolder(View itemView) {
super(itemView);
foodImage = itemView.findViewById(R.id.food_image);
foodTitle = itemView.findViewById(R.id.food_title_homepage);
ingredients = itemView.findViewById(R.id.ingredients_homepage);
foodItem = itemView.findViewById(R.id.card_food_item);
}
}
#NonNull
#Override
public FoodViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_homepage_food_item, parent, false);
return new FoodViewHolder(v);
}
#Override
public void onBindViewHolder(#NonNull FoodViewHolder holder, int position) {
final Food currentFood = foods.get(position);
StringBuilder food_ingredient_str = new StringBuilder();
int ingredient_position = 0;
int ingredients_size = currentFood.getFood_ingredients().size();
for (Food.FoodIngredient foodIngredient : currentFood.getFood_ingredients()) {
food_ingredient_str.append(foodIngredient.getIngredient());
if (ingredient_position != ingredients_size / 3)
food_ingredient_str.append(", ");
if (ingredient_position == ingredients_size / 3) {
food_ingredient_str.append(" و ...");
break;
}
ingredient_position += 1;
}
holder.foodTitle.setText(currentFood.getName());
holder.ingredients.setText(food_ingredient_str);
holder.foodItem.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putSerializable("current_food", currentFood);
Navigation.findNavController(v).navigate(R.id.action_navigation_home_to_navigation_food, bundle);
}
});
}
#Override
public int getItemCount() {
return foods.size();
}
If you want to create a list using recyclerview and each item to be right aligned as in Arabic.. then try these approaches
replace your "recycle_view_item_layout.xml" with this
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_food_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="4dp">
<LinearLayout
android:id="#+id/linear_food_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="4dp">
<LinearLayout
android:id="#+id/food_contents"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/food_title_homepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:ellipsize="start"
android:fontFamily="#font/sans_regular"
android:singleLine="true"
android:text="عنوان غذا"
android:textAppearance="#style/TextAppearance.AppCompat.Title" />
<TextView
android:id="#+id/ingredients_homepage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:ellipsize="start"
android:fontFamily="#font/sans_regular"
android:singleLine="true"
android:text="مواد اولیه"
android:textAppearance="#style/TextAppearance.MaterialComponents.Subtitle1" />
</LinearLayout>
<com.mikhaellopez.circleview.CircleView
android:id="#+id/food_image"
android:layout_width="80dp"
android:layout_height="80dp"
app:cv_color="#color/colorAccent" />
</LinearLayout>
</androidx.cardview.widget.CardView>
replace your "recycle view" with this
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recipes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/homepage_toolbar"
tools:listitem="#layout/fragment_homepage_food_item" />
and attach a layout manager like this (important)
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
setRecyclerView(layoutManager);
and rest of your code seems okay
I am using CardStackView library but I also want to scroll its item and the only swap left and right
public class CardFragment extends Fragment implements CardStackListener {
private View view;
FragmentCardBinding binding;
CardStackLayoutManager manager;
CardStackAdapter cardStackAdapter;
private List<CardModel> listCard = new ArrayList<CardModel>();
public static MyAppAdapter myAppAdapter;
public static ViewHolder viewHolder;
private ArrayList<Data> array;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_card, container, false);
manager = new CardStackLayoutManager(getContext());
listCard.add(new CardModel("MaryBurgess", "steattle, USA", "USA", R.drawable.imggirl));
listCard.add(new CardModel("MaryBurgess", "steattle, USA", "USA", R.drawable.imggirl));
listCard.add(new CardModel("MaryBurgess", "steattle, USA", "USA", R.drawable.imggirl));
listCard.add(new CardModel("MaryBurgess", "steattle, USA", "USA", R.drawable.imggirl));
manager.setStackFrom(StackFrom.None);
manager.setVisibleCount(3);
manager.setTranslationInterval(8.0f);
manager.setScaleInterval(0.95f);
manager.setSwipeThreshold(0.3f);
manager.setMaxDegree(20.0f);
manager.setDirections(Direction.HORIZONTAL);
manager.setCanScrollHorizontal(true);
manager.setCanScrollVertical(true);
binding.cardStackView.setLayoutManager(manager);
cardStackAdapter = new CardStackAdapter(listCard, getActivity());
binding.cardStackView.setAdapter(cardStackAdapter);
binding.imgFilter.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), LookingFor.class);
startActivity(intent);
getActivity().finish();
}
});
myAppAdapter = new MyAppAdapter(listCard, getContext());
return view = binding.getRoot();
}
#Override
public void onCardDragging(Direction direction, float ratio) {
}
#Override
public void onCardSwiped(Direction direction) {
Log.d("CardStackView", String.valueOf(direction));
}
#Override
public void onCardRewound() {
}
#Override
public void onCardCanceled() {
}
here is adapter class
public class CardStackAdapter extends RecyclerView.Adapter<CardStackAdapter.ViewHolder> {
private List<CardModel> listCard = new ArrayList<CardModel>();
private Context c;
public CardStackAdapter(List<CardModel> listCard,Context c ) {
this.listCard = listCard;
this.c = c;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_item, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
holder.username.setText(listCard.get(position).getName());
holder.cityName.setText(listCard.get(position).getCity());
Glide.with(holder.item_image)
.load(listCard.get(position).getUserImage())
.into(holder.item_image);
}
#Override
public int getItemCount() {
return listCard.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView username, cityName;
RoundedImageView item_image;
public ViewHolder(#NonNull View itemView) {
super(itemView);
username = itemView.findViewById(R.id.user_name);
cityName = itemView.findViewById(R.id.city_name);
item_image = itemView.findViewById(R.id.item_image);
}
}
}
and adapter XML :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:id="#+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:foreground="?attr/selectableItemBackground"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="8dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true">
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/item_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/imggirl"
app:riv_corner_radius="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="20dp"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.bugfreecode.anotherchanz.fonts.GothamBookBold
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MaryBurgess"
android:textColor="#android:color/white"
android:textSize="26sp"
android:textStyle="bold" />
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="#drawable/verified" />
</LinearLayout>
<TextView
android:id="#+id/city_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Steattle, USA"
android:textColor="#android:color/white"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<FrameLayout
android:id="#+id/left_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="#drawable/dislike" />
<FrameLayout
android:id="#+id/bottom_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</FrameLayout>
<FrameLayout
android:id="#+id/right_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="#drawable/like" />
</FrameLayout>
<FrameLayout
android:id="#+id/top_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:id="#+id/lytChips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:layout_marginRight="15dp"
android:orientation="vertical">
<com.google.android.material.chip.ChipGroup
android:id="#+id/choice_chip_group"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
card_view:iconStartPadding="10dp"
card_view:chipIconSize="15dp"
android:drawablePadding="5dp"
android:id="#+id/choice_chip5"
android:textColor="#color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Architecture/Interior design"
android:textAppearance="#style/AppTheme.GenderChip"
android:theme="#style/Theme.MaterialComponents.Light"
app:chipStartPadding="8dp"
app:chipStrokeWidth="1dp" />
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
fragment XML
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#drawable/gradiant_back">
<com.bugfreecode.anotherchanz.fonts.GothamBookBold
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="30dp"
android:gravity="center"
android:letterSpacing="0.23"
android:singleLine="true"
android:text="Anotherchanz"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="23sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imgFilter"
android:layout_marginEnd="20dp"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:src="#drawable/ic_filler" />
</LinearLayout>
<LinearLayout
android:background="#drawable/back_full"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- <com.lorentzos.flingswipe.SwipeFlingAdapterView
android:id="#+id/flingContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gradiant_back"
app:rotation_degrees="15.5" />-->
<com.yuyakaido.android.cardstackview.CardStackView
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:id="#+id/card_stack_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.yuyakaido.android.cardstackview.CardStackView>
</LinearLayout>
</LinearLayout>
Card swap is working perfectly but I want to make card scroll vertically also I have used scroll view in adapter items but it is not working its only working for swap, please help me I would appreciate every answer.
I know there is probably a very simple solution out there, but for the life of me I can't seem to find it. How do I change the width of the RecycleView item? For some reason, it's displaying the first item full width of the parent... It's displaying a lot of white space in between each item.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/main_wrapper"
android:background="#color/colorPrimary"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:padding="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Categories"
android:textColor="#ffffff"
android:layout_marginBottom="10dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cats"
></android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
CategoryAdapter:
public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.ViewHolder> {
private ArrayList<Category> categories;
public CategoryAdapter(ArrayList<Category> categories) {
this.categories = categories;
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_cat, parent, false);
return new ViewHolder(v);
}
#Override public void onBindViewHolder(ViewHolder holder, int position) {
Category cat = this.categories.get(position);
holder.text.setText(cat.getText().toString());
}
#Override public int getItemCount() {
return categories.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView text;
public ViewHolder(View itemView) {
super(itemView);
text = (TextView) itemView.findViewById(R.id.cat_title);
}
}
}
single_cat.xml
<TextView
android:layout_width="100dp"
android:layout_height="40dp"
android:text="Cat"
android:background="#drawable/cat_single_shape"
android:padding="10dp"
android:gravity="center"
android:id="#+id/cat_title"
android:textSize="13sp"
android:fontFamily="#font/open_sans_bold"
android:textColor="#color/colorPrimary"/>
1)in your fragment do :
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, true));
2)for recyclerView single item .xml do :
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_margin="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
3) and change RecyclerView to :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/main_wrapper"
android:background="#color/colorPrimary"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:text="Categories"
android:textColor="#ffffff"
android:layout_marginBottom="10dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.8"
android:id="#+id/cats"/>
</LinearLayout>
i would change single cat to
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/cat_single_shape"
android:padding="10dp"
android:gravity="center"
android:id="#+id/cat_title"
android:textSize="13sp"
android:fontFamily="#font/open_sans_bold"
android:textColor="#color/colorPrimary"/>
Finally, after 2 days and looking all over the internet, I figured it out myself.
Make sure your Constraint Layout is wrap_content. This was the issue all along!
i just want to replace a fragment by using this code:
fragmentManager.beginTransaction()
.replace(R.id.homepage_fragment_menu, fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
the fragment has recyclerview. but when i see the result of fragment, there's no shown of recyclerview. but when i checked in LayoutInspector, it's showed, but invisible like
this
And here's the code when set the adapter on RecyclerView
bookingHistoryProgressBar.setVisibility(View.GONE);
bookingHistoryList.setVisibility(View.VISIBLE);
adapterBookingHistoryList = new AdapterBookingHistoryList(this, bookingHistoryListModels);
bookingHistoryList.setAdapter(adapterBookingHistoryList);
Here's the layout code for RecyclerView and Adapter
XML Fragment Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/grey"
tools:context=".home.bookinghistorypage.BookingHistoryFragment"
android:gravity="center">
<android.support.v7.widget.RecyclerView
android:id="#+id/bookingHistory_listBooking"
android:background="#color/white_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
Adapter
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/booking_history_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="6dp"
app:cardElevation="6dp"
android:layout_marginTop="#dimen/margin_small"
android:layout_marginBottom="#dimen/margin_small"
app:cardUseCompatPadding="true">
<LinearLayout
android:background="#color/white"
android:paddingLeft="#dimen/padding_large"
android:paddingRight="#dimen/padding_large"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<helper.CustomFontMontserratBoldTextView
android:id="#+id/booking_history_name"
android:layout_marginTop="#dimen/margin_large"
android:layout_marginBottom="3dp"
android:textColor="#color/black"
android:textSize="#dimen/text_medium"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<helper.CustomFontMontserratMediumTextView
android:id="#+id/booking_history_code"
android:gravity="end"
android:layout_marginTop="#dimen/margin_large"
android:layout_marginBottom="#dimen/margin_small"
android:textColor="#color/grey_2"
android:textSize="#dimen/text_medium"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<helper.CustomFontMontserratBoldTextView
android:id="#+id/booking_history_status"
android:background="#color/lightOrange"
android:textColor="#color/black"
android:textSize="#dimen/text_very_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:paddingBottom="#dimen/padding_small"
android:layout_marginBottom="#dimen/padding_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:layout_marginBottom="#dimen/padding_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:src="#mipmap/ic_tanggal"
android:layout_width="20dp"
android:layout_height="20dp" />
<helper.CustomFontMontserratRegularTextView
android:visibility="gone"
android:id="#+id/booking_history_day_booked"
android:layout_marginStart="#dimen/margin_small"
android:layout_marginLeft="#dimen/margin_small"
android:textColor="#color/grey"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<helper.CustomFontMontserratMediumTextView
android:id="#+id/booking_history_actual_date"
android:layout_marginStart="#dimen/margin_small"
android:layout_marginLeft="#dimen/margin_small"
android:textColor="#color/grey"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<helper.CustomFontMontserratMediumTextView
android:id="#+id/booking_history_time_booked"
android:layout_marginStart="#dimen/margin_medium"
android:layout_marginLeft="#dimen/margin_medium"
android:textColor="#color/grey"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
XML Activity (Parent of Fragment)
<com.flipboard.bottomsheet.BottomSheetLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/bottomsheet"
android:background="#color/black_image_view">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_height="?android:attr/actionBarSize"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_title_and_description"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/homepage_fragment_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/appbar_layout"
android:layout_above="#id/navigation"
/>
<include
android:id="#+id/navigation"
layout="#layout/element_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
<ProgressBar
android:id="#+id/homepage_progressBar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
</com.flipboard.bottomsheet.BottomSheetLayout>
AdapterJava
#NonNull
#Override
public BookingHistoryListViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View view = layoutInflater.inflate(R.layout.adapter_booking_history,parent,false);
context = parent.getContext();
return new BookingHistoryListViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull final BookingHistoryListViewHolder holder, final int position) {
String data = GetDateUtils.convertEpochToDate(dataList.get(position).getActualDate());
if(dataList.get(position).getBookingStatus().equals("Completed") && dataList.get(position).getFlagRating().equals(false)){
Intent intent = new Intent(holder.itemView.getContext(), ProfessionalRatingActivity.class);
intent.putExtra("professionalId", dataList.get(position).getProfessionalId());
intent.putExtra("expertiseId", dataList.get(position).getExpertiseId());
intent.putExtra("professionalName",dataList.get(position).getProfessionalName());
holder.itemView.getContext().startActivity(intent);
}
if(dataList.get(position).getBookingStatus().equals("OnProcess")){
holder.bookingHistoryStatus.setBackgroundColor(ContextCompat.getColor(this.context,R.color.on_process));
}else if(dataList.get(position).getBookingStatus().equals("Cancel")){
holder.bookingHistoryStatus.setBackgroundColor(ContextCompat.getColor(this.context,R.color.cancelled));
}else if(dataList.get(position).getBookingStatus().equals("Completed")){
holder.bookingHistoryStatus.setBackgroundColor(ContextCompat.getColor(this.context,R.color.completed));
}else if(dataList.get(position).getBookingStatus().equals("Reserved")){
holder.bookingHistoryStatus.setBackgroundColor(ContextCompat.getColor(this.context,R.color.reserved));
}else if(dataList.get(position).getBookingStatus().equals("Reschedule")){
holder.bookingHistoryStatus.setBackgroundColor(ContextCompat.getColor(this.context,R.color.rescheduled));
}else if(dataList.get(position).getBookingStatus().equals("Confirmed")){
holder.bookingHistoryStatus.setBackgroundColor(ContextCompat.getColor(this.context,R.color.confirmed));
}
holder.bookingHistoryName.setText(dataList.get(position).getProfessionalName());
holder.bookingHistoryStatus.setText(dataList.get(position).getBookingStatus());
holder.bookingHistoryDayBooked.setText(dataList.get(position).getDayBooked());
holder.bookingHistoryCode.setText(String.format(Locale.getDefault(),"ID: %s",dataList.get(position).getCode()));
holder.bookingHistoryActualDate.setText(String.format(Locale.getDefault(),"%s",data));
holder.bookingHistoryTimeBooked.setText(String.format(Locale.getDefault(),"# %s",dataList.get(position).getTimeBooked()));
holder.bookingHistoryCardview.setOnClickListener(v -> {
Intent intent = new Intent(v.getContext(), BookingHistoryDetailActivity.class);
intent.putExtra("idProfessionalAdapter", dataList.get(position).getId());
holder.itemView.getContext().startActivity(intent);
});
}
#Override
public int getItemCount() {
return dataList!=null ? dataList.size() :0 ;
}
You're nesting your fragment view in a BottomSheetLayout, and according to the source code, the initial visibility is View.INVISIBLE:
private void init() {
// ...
dimView = new View(getContext()); // Line 150
dimView.setBackgroundColor(Color.BLACK);
dimView.setAlpha(0);
dimView.setVisibility(INVISIBLE);
// ...
}
public void setContentView(View contentView) {
super.addView(contentView, -1, generateDefaultLayoutParams());
super.addView(dimView, -1, generateDefaultLayoutParams());
}
I'm not familiar with Flipboard library, but I've got a feeling that you might be using it incorrectly. Maybe try:
bottomSheetLayout.showWithSheetView(...)
Or please check on their GitHub for usage.
Your recycler view in xml layout has `android:visibility="gone". Remove this line or change it to visible.
I am making android cv app and I have implemented RecyclerView but items not scrolling even though, I have used RecyclerViewLayout Manager.
below my SkillsAdapter.class
public class SkillsAdapter extends RecyclerView.Adapter {
public List skillList;
public Context context;
public SkillsAdapter(List<Skill> skillList, Context context) {
this.skillList = skillList;
this.context = context;
}
#NonNull
#Override
public SkillsAdapter.ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(context)
.inflate(R.layout.skills_item, parent, false); // change
return new SkillsAdapter.ViewHolder(itemView);
}
#Override
public void onBindViewHolder(#NonNull SkillsAdapter.ViewHolder holder, int position) {
Skill skill = skillList.get(position);
holder.programming.setText(skill.getProgramming());
holder.framework.setText(skill.getFrameworkLibraries());
holder.architecture.setText(skill.getAndroidArchitectureComponents());
holder.software.setText(skill.getSoftwareMethodologies());
holder.ide.setText(skill.getIDES());
}
#Override
public int getItemCount() {
return skillList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView programming, framework, architecture, software, ide;
public ViewHolder(View view) {
super(view);
programming= (TextView) view.findViewById(R.id.programming);
framework = (TextView) view.findViewById(R.id.framework);
architecture = (TextView) view.findViewById(R.id.architecture);
software = (TextView) view.findViewById(R.id.software);
ide = (TextView)view.findViewById(R.id.ide);
}
}
}
below my SkillsItem.java class
public class SkillItem extends AppCompatActivity {
private SkillsAdapter skillsAdapter;
public List<Skill> skillList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.skills);
KitabInterface kitabInterface = ApiClient.getApiService();
Call<KitabSawti> call = kitabInterface.getSkills();
call.enqueue(new Callback<KitabSawti>() {
#Override
public void onResponse(Call<KitabSawti> call, Response<KitabSawti> response) {
skillList= response.body().getSkills();
RecyclerView recyclerView = findViewById(R.id.recyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
skillsAdapter = new SkillsAdapter( skillList, SkillItem.this); // changes
recyclerView.setAdapter(skillsAdapter);
}
#Override
public void onFailure(Call<KitabSawti> call, Throwable t) {
}
});
}
}
below my skills_items.xml where I have implemented items
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorBlust"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<ImageView
android:id="#+id/educationImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/it_skills"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/education_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="#string/text_skills"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/subjectImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/programming_skills"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/programming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/programming_skills"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/framework_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/it_frameworks"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/framework"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/text_framework"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/android_component"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/android_components"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/architecture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/architecture"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/software_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/software_methodologies"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/software"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/software"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlust"
android:orientation="horizontal"
android:padding="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/software_ide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/software_ide"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/ide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="100dp"
android:layout_marginLeft="100dp"
android:text="#string/ides"
android:textColor="#color/colorWhite"
android:textSize="20sp" />
<View style="#style/dividerHorizontal" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
below my skills.xml where I have hosted RecyclerView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
below screenshot
current ui
The problem is, that the root layout of your item (the root LinearLayout at skills_items.xml) has height of match_parent. This messes up the way RecyclerView does the scrolling event calculations.
Also, it is generally advised against using wrap_content for height or width of the root layout for an activity and for wrap_content for height (if scroll is vertical) or width (if scroll is horizontal) of RecyclerView or ListView.