my problem is that any text views inside any items of all recyclerview don't take its font from XML, just shows the original font of the android
only items of all recycler views have this issue, other text views work fine
I have a lot of recycler view around 23 rv and there is more so it's not a good thing to change every text font programmatically I tried many things with no luck here any help?
this is an example: Adaptor view
import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.ecom.R
import com.ecom.data.model.FabricProduct
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.item_fabric_product.view.*
class CollectionAdaptor(var mList: List<FabricProduct>, var context: Context, val listener: (FabricProduct) -> Unit
) : RecyclerView.Adapter<CollectionViewHolder>() {
fun updateList(newitems: List<FabricProduct>) {
mList = newitems
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CollectionViewHolder {return CollectionViewHolder( LayoutInflater.from(context).inflate(R.layout.item_fabric_product,parent,false))
}
override fun onBindViewHolder(holder: CollectionViewHolder, position: Int) {
holder.bind(mList[position], listener)
}
override fun getItemCount(): Int {
return mList.size
}}
class CollectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind(item: FabricProduct, listener: (FabricProduct) -> Unit) = with(itemView) {
itemView.text_subcategorie_slogan.text = item.slogan
itemView.text_subcategorie_title.text = item.title
setOnClickListener { listener(item) }
}}
recyclerview setup
mFabricProductlist = FakeData.getFabricCollection()
rootView.rv_collection_subcategory.layoutManager = GridLayoutManager(activity!!.applicationContext, 2)
mCollectionAdaptor =
CollectionAdaptor(mFabricProductlist as List<FabricProduct>, activity!!.applicationContext) { //get the selected item here}
rootView.rv_collection_subcategory.adapter = mCollectionAdaptor
inside a fragment_collection.xml
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_collection_subcategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
item.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="220dp"
android:layout_marginStart="15dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="4dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="10dp"
android:layout_marginStart="4dp"
android:orientation="vertical">
<TextView
android:id="@+id/text_subcategorie_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat_bold"
android:shadowColor="#000"
android:shadowDy="1"
android:shadowRadius="1"
android:text="000"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/text_subcategorie_slogan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat"
android:shadowColor="#000"
android:shadowDy="1"
android:shadowRadius="2"
android:text="000"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
</FrameLayout>
build.gradle
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-
core:3.2.0-alpha03'
//Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'