-1

Is there any way to Design In Android Studio, to Design edittext with multipleScreen support without using padding and margin in .xml?

My code is not supporting the multiple screen(it exceed the screen). Please help me to design a code which support multiple screen inside screen.

mostly desin should not be designed using padding and margine.

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center_horizontal|center"
android:gravity="center_horizontal|center_vertical"
android:weightSum="3"
tools:context=".MainActivity">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="MOBILE"
        />

</RelativeLayout>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    android:layout_weight="1"
</RelativeLayout>
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1">

</RelativeLayout>

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></LinearLayout>

Abhinav Singh Maurya
  • 3,303
  • 8
  • 32
  • 50
Rahul
  • 404
  • 4
  • 16

2 Answers2

0

Create your interface by code and set its elements size on px, so you will never have any hardcoded dimension and it will look OK in all screens.

Take a look at this

Hope this helps.

Community
  • 1
  • 1
Nanoc
  • 2,381
  • 1
  • 19
  • 35
0

Whenever you are using weights with VERTICAL LinearLayout, give the height of child 0dp. Try this code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="3">


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Mobile"
        android:layout_centerInParent="true"/>
</RelativeLayout>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Mobile"
        android:layout_centerInParent="true"/>
</RelativeLayout>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Mobile"
        android:layout_centerInParent="true"/>
</RelativeLayout>

Hope it helps. Thank you

Prakhar
  • 748
  • 6
  • 23