What could be the problem, on different devices the application is displayed differently, and the font in the TextView set to android:typeface="serif" , but it works only on android 4.4

Android 4.4

enter image description here

Android 5.0.1

enter image description here

Android 5.0.0

enter image description here

They are all 1080 * 1920 - 480dpi, the 1st case is the Galaxy S4 (Android 4.4.4) - API 19 is a virtual device, 2nd Galaxy S4 (Android 5.0.1) - API 21 is a real device, 3rd Nexus 5 (Android 5.0.0) - API 21 is a virtual device.
There is no folder with the -v21 qualifier in the resources .

Activity is inherited from AppCompatActivity , and fragment from Fragment .

If I understand correctly, then the problem is in RecyclerView itself, since need to add one generic addItemDecoration() , but how to do it?

Here is the code to add the RecyclerView adapter :

 rvCategories = (RecyclerView) view.findViewById(R.id.rv); adapter = new CategoryAdapter(getContext(), addCategories(TYPE), TYPE, null); GridLayoutManager glm = new GridLayoutManager(getActivity(), 2, GridLayoutManager.HORIZONTAL, false); rvCategories.setAdapter(adapter); rvCategories.setLayoutManager(glm); rvCategories.setLayoutManager(glm); rvCategories.setHasFixedSize(true); rvCategories.addItemDecoration(**вот тут что?**); 
  • And as far as I remember, the fonts can only be set using typeface from 4.4, so on younger versions they look different - pavel163
  • @ pavel163, so I’m checking it higher than 4.4 - java

1 answer 1

1) The answer to the problem with indents in RecyclerView found here

 mRecyclerView.setLayoutManager(new GridLayoutManager(context, NUM_COLUMNS); ItemOffsetDecoration itemDecoration = new ItemOffsetDecoration(context, R.dimen.item_offset); mRecyclerView.addItemDecoration(itemDecoration); 

2) The problem with the font here

You also need to register the MyApp class in AndroidManifest.xml

 <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name=".MyApp"> ... </application>