How to level away Androids
-
I'm making a player on the Android. Dana next marking:
There is one Activity consisting of two three fragments:
- The main fragment with the scrub.
- Floating fragment. This block only shows up if the track plays
Navigation menu, like instagram.
P.S. The floating fragment and menu are always down there! (sighs)
android:layout_alignParentBottom="true"
)
Question: If the player doesn't play, then the floating fragment will be missing and filled with main fragment. Method
layout.setPadding(0,0,0,125);
It doesn't work. On different devices, derogations can be on the floor of the screen. How do I get it?
-
You're fixing the retraction value 125, but on different screens, try to convert the backset value to the corresponding screen density:
/** * This method converts device specific pixels to density independent pixels. * * @param px A value in px (pixels) unit. Which we need to convert into dp * @param context Context to get resources and device specific display metrics * @return A float value to represent dp equivalent to px value */ public static float convertPixelsToDp(float px, Context context){ Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); float dp = px / (metrics.densityDpi /160f); return dp; }