I faced a problem with DialogFragment. The layout is changing depending on the API. I use a PercentRelativeLayout.
- For API >= 21, the sizes are percentages of the screen and there is no title.
- Pof API < 21, the sizes change (I guess they are percentages of the Dialog's size) and there is a title.
There are 2 pictures below to show the problem.
It was easy to find how to delete the title but for the percentage I have no idea how to do. Do you know an easy way to solve it? Additive question: in my research I read PercentRelativeLayout will be deprecated. is there a better way for doing my layout?
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_dialog2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/round">
<TextView
android:id="@+id/text"
app:layout_marginTopPercent="3%"
app:layout_heightPercent="26%"
app:layout_widthPercent="100%"
android:text="@string/rate"
android:textSize="@dimen/button"
android:textColor="#1565c0"
android:gravity="center_horizontal"/>
<Button
android:text="@string/yes"
android:background="@drawable/button"
android:textColor="#FFFFFF"
android:textAllCaps="false"
android:textSize="@dimen/button"
app:layout_widthPercent="20%"
app:layout_heightPercent="6%"
android:id="@+id/buttonY"
app:layout_marginTopPercent="20%"
app:layout_marginLeftPercent="27%"/>
<Button
android:text="@string/no"
android:background="@drawable/button"
android:textColor="#FFFFFF"
android:textAllCaps="false"
android:textSize="@dimen/button"
app:layout_widthPercent="20%"
app:layout_heightPercent="6%"
android:id="@+id/buttonN"
app:layout_marginTopPercent="20%"
app:layout_marginLeftPercent="53%"/>
</android.support.percent.PercentRelativeLayout>