0

I am working with the SQLite Database and want to create a Layout Responsive for all the Devices, but I have no idea,How to create it.

When I tried to change this layout to the linear layout then after running the app it shows me app has stopped working.

Here is the XML File of the layout

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:paddingBottom="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="20dp"
tools:context=".activities.LoginActivity">

<android.support.v7.widget.LinearLayoutCompat
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.AppCompatImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="40dp"
        android:src="@drawable/logo" />



<android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayoutName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/textInputEditTextName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_name"
            android:inputType="text"
            android:maxLines="1"
            android:textColor="@android:color/white" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayoutEmail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/textInputEditTextEmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_email"
            android:inputType="text"
            android:maxLines="1"
            android:textColor="@android:color/white" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayoutPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

To be continue..

<android.support.design.widget.TextInputEditText
            android:id="@+id/textInputEditTextPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_password"
            android:inputType="textPassword"
            android:maxLines="1"
            android:textColor="@android:color/white" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayoutConfirmPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/textInputEditTextConfirmPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_confirm_password"
            android:inputType="textPassword"
            android:maxLines="1"
            android:textColor="@android:color/white" />
    </android.support.design.widget.TextInputLayout>

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/appCompatButtonRegister"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:background="@color/colorTextHint"
        android:text="@string/text_register" />

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/appCompatTextViewLoginLink"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:gravity="center"
        android:text="Already a member? Login"
        android:textSize="16dp" />
</android.support.v7.widget.LinearLayoutCompat>

I have changed the layout to Linear and relative and then It become responsive but after running app it shows app stop working and in the Logcat the errors are

Error Logcat

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
Usman Ali
  • 425
  • 1
  • 9
  • 31

1 Answers1

1

Try this

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/nestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/text_gray"
        android:paddingBottom="20dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="20dp">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

                // Your other Code here.....

    </android.support.v4.widget.NestedScrollView>
    </android.support.constraint.ConstraintLayout>

In between past your code and use the constraintlayout.

Viral Patel
  • 1,296
  • 1
  • 11
  • 24