<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp"/>
<gradient android:startColor="@color/red2" android:angle="90"
android:endColor="@color/red1"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp"/>
<gradient android:startColor="@color/green2"
android:angle="90"
android:endColor="@color/green1"/>
</shape>
package com.daizzyinfosys.orderentry.models;
public class ModelTest {
String Title,date;
public ModelTest(String title, String date) {
Title = title;
this.date = date;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
}
package com.daizzyinfosys.orderentry.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.daizzyinfosys.orderentry.R;
import com.daizzyinfosys.orderentry.models.ModelTest;
import com.google.android.material.imageview.ShapeableImageView;
import java.util.List;
public class AdapterTest extends RecyclerView.Adapter<AdapterTest.VHTest> {
Context context;
List<ModelTest> modelTests;
public AdapterTest(Context context, List<ModelTest> modelTests) {
this.context = context;
this.modelTests = modelTests;
}
@NonNull
@Override
public VHTest onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.custom_rv_test_item,parent,false);
return new VHTest(view);
}
@Override
public void onBindViewHolder(@NonNull VHTest holder, int position) {
holder.txtTitle.setText(modelTests.get(position).getTitle());
holder.txtDate.setText(modelTests.get(position).getDate());
if(position%2==0)
{
holder.lnBg.setBackground(context.getResources().getDrawable(R.drawable.bg_gradient));
}
else
{
holder.lnBg.setBackground(context.getResources().getDrawable(R.drawable.bg_gradient2));
}
// if (position == 0) {
// holder.lnBg.setBackground(context.getResources().getDrawable(bg_gradient));
// } else {
// holder.lnBg.setBackground(context.getResources().getDrawable(bg_gradient2));
// }
}
@Override
public int getItemCount() {
return modelTests.size();
}
public class VHTest extends RecyclerView.ViewHolder {
ShapeableImageView lnBg;
TextView txtTitle,txtDate;
public VHTest(@NonNull View itemView) {
super(itemView);
txtDate=itemView.findViewById(R.id.txtDate);
txtTitle=itemView.findViewById(R.id.txtTitle);
lnBg=itemView.findViewById(R.id.lnBg);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_height="match_parent">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/lnBg"
android:scaleType="fitEnd"
android:layout_width="250dp"
android:padding="1dp"
android:layout_height="140dp"
android:layout_marginTop="1dp"
android:layout_marginHorizontal="5dp"
android:background="@drawable/bg_gradient"
app:shapeAppearanceOverlay="@style/FoodStyle"
android:src="@drawable/gradient_bg"
>
</com.google.android.material.imageview.ShapeableImageView>
<LinearLayout
android:id="@+id/ln"
android:layout_width="250dp"
android:padding="10dp"
android:orientation="vertical"
android:layout_marginHorizontal="5dp"
android:layout_height="140dp"
android:layout_marginTop="1dp"
android:elevation="5dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginVertical="20dp"
android:orientation="vertical"
>
<TextView
android:id="@+id/txtTitle"
android:fontFamily="@font/roboto_regular"
android:textSize="18sp"
android:textColor="@color/whiteLight"
android:layout_marginHorizontal="20dp"
android:paddingVertical="1dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="A PromotionalOffer is \ncall to action on the"
>
</TextView>
<TextView
android:id="@+id/txtDate"
android:layout_marginTop="10dp"
android:fontFamily="@font/roboto_medium"
android:textSize="16sp"
android:textColor="@color/whiteLight"
android:layout_marginHorizontal="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" 20 May 2023"
>
</TextView>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
protected void ImageSlider(){
ArrayList<SlideModel>slideModels = new ArrayList<>();
slideModels.add(new SlideModel(R.drawable.v_home,ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.v_home,ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.v_home,ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.v_home,ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.v_home,ScaleTypes.FIT));
slideModels.add(new SlideModel(R.drawable.v_home,ScaleTypes.FIT));
imageSlider.setImageList(slideModels,ScaleTypes.FIT);
}
Comments
Post a Comment