I am working on a form layout for a Login Activity
in my Android App. The image below is how I want it to look like:
You cannot use percentages to define the dimensions of a View inside a RelativeLayout. The best ways to do it is to use LinearLayout and weights, or a custom Layout.
Update
As pointed by @EmJiHash PercentRelativeLayout and PercentFrameLayout is deprecated in API level 26.0.0
Consider Using ConstraintLayout
Google introduced new API called android.support.percent
1)PercentRelativeLayout
2)PercentFrameLayout
Add compile dependency like
compile 'com.android.support:percent:23.1.1'
You can specify dimension in percentage so get both benefit of RelativeLayout
and percentage
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
app:layout_widthPercent="40%"
app:layout_heightPercent="40%"
app:layout_marginTopPercent="15%"
app:layout_marginLeftPercent="15%"/>
</android.support.percent.PercentRelativeLayout/>