Every time I add widgets or stuff, below exception always occurs, so I can't even run my project. What causes this problem? What is the solution? I'm very new to Android Studio, and I hope you guys will help me. Every answer of you will be my pleasure. Thanks!
Here is my Layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.leeroyld.testproject.MainActivity">
<Button
android:text="#string/LoginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button"
android:layout_marginBottom="79dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#android:color/background_dark"
android:backgroundTint="#android:drawable/bottom_bar"
android:textColor="#android:color/background_light" />
<TextView
android:text="#string/LoginLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/EmailDisplay"
android:textSize="24sp"
android:layout_below="#+id/textView"
android:layout_alignParentStart="true"
android:layout_marginTop="36dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/PasswordInput"
tools:ignore="LabelFor"
android:layout_marginBottom="42dp"
android:layout_above="#+id/button"
android:layout_centerHorizontal="true"
android:background="?attr/actionModeBackground" />
<TextView
android:text="#string/PasswordLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/PasswordDisplay"
android:textSize="24sp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
<TextView
android:text="#string/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:textSize="24sp"
android:layout_marginTop="31dp"
android:background="#android:drawable/button_onoff_indicator_on"
android:backgroundTint="#android:drawable/alert_light_frame"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/EmailInput"
tools:ignore="LabelFor"
android:layout_marginTop="24dp"
android:background="?attr/actionModeBackground"
android:layout_below="#+id/EmailDisplay"
android:layout_alignStart="#+id/PasswordInput" />
</RelativeLayout>
Remove the android:backgroundTint from LoginButton and TextView. Your final layout should look like this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="79dp"
android:background="#android:color/background_dark"
android:text="Login"
android:textColor="#android:color/background_light" />
<TextView
android:id="#+id/EmailDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:layout_marginTop="36dp"
android:text="Email"
android:textSize="24sp" />
<EditText
android:id="#+id/PasswordInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button"
android:layout_centerHorizontal="true"
android:layout_marginBottom="42dp"
android:background="?attr/actionModeBackground"
android:ems="10"
android:inputType="textPassword"
tools:ignore="LabelFor" />
<TextView
android:id="#+id/PasswordDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Password"
android:textSize="24sp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="31dp"
android:background="#android:drawable/button_onoff_indicator_on"
android:text="TextView"
android:textSize="24sp" />
<EditText
android:id="#+id/EmailInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/EmailDisplay"
android:layout_marginTop="24dp"
android:background="?attr/actionModeBackground"
android:ems="10"
android:inputType="textEmailAddress"
tools:ignore="LabelFor" />
</RelativeLayout>
Related
The following file is intended to allow full vertical scrolling in Android devices.
However when opening the app in Android Studio the light blue rectangular box ends just before where the buttons begin. Does not scroll. Members of Stack Overflow have helped me to overcome the file not opening. I thank them. But issue of scrolling remains.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
tools:showIn="#layout/activity_main">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/scrollView"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView android:id="#+id/imageView"
android:layout_column="1"
android:background="#mipmap/lpussy"
android:contentDescription='android:ContentDescription="#string/desc"'
tools:ignore="HardcodedText"
android:layout_width="200dp"
android:layout_height="230dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" We've been ... "
android:id="#+id/text1"
android:layout_alignTop="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:text="Cancun, Playa del Carmen, ..."
android:layout_below="#+id/text1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="Holbox, ..."
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageButton"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#mipmap/campa"
tools:ignore="ContentDescription"
android:layout_alignBottom="#+id/editText5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText3"
android:text="thewebmaster#cancunsteve.com"
android:layout_below="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_alignEnd="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText4"
android:text=" 011 52 998 8873919"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText5"
android:text="be sure ..."
android:layout_below="#+id/editText4"
android:layout_toRightOf="#+id/ScrollView"
android:layout_toEndOf="#+id/ScrollView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click buttons multiple times to change state"
android:id="#+id/textView2"
android:layout_below="#+id/imageButton" />
</RelativeLayout>
</ScrollView>
The content_mail.xml file will not open. I am attempting to produce a ScrollView for the entire android screen for all views within. Code follows this is a revision of prior code posted:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
tools:showIn="#layout/activity_main">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp" />
<ImageView android:id="#+id/imageView"
android:layout_column="1"
android:background="#mipmap/lpussy"
android:contentDescription='android:ContentDescription="#string/desc"'
tools:ignore="HardcodedText"
android:layout_width="200dp"
android:layout_height="230dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" We've been serving good people like you since 1994 with special deals on their travel plans. "
android:id="#+id/text1"
android:layout_alignTop="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:text="Cancun, Chichen Itza."
android:layout_below="#+id/text1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="Holbox, Taxco, Palenque, Acapulco, Ixtapa, Guanajuato,
Cabo San Lucas, Puerto Vallarta, Monterrey, Tenacatita, Mascota"
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageButton"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#mipmap/campa"
tools:ignore="ContentDescription"
android:layout_alignBottom="#+id/editText5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText3"
android:text="thewebmaster#cancunsteve.com"
android:layout_below="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_alignEnd="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText4"
android:text=" 011 52 998 8873919"
android:layout_below="#+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText5"
android:text="be sure to visit us discounts on your hotel bookings"
android:layout_below="#+id/editText4"
android:layout_toRightOf="#+id/scrollView"
android:layout_toEndOf="#+id/scrollView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click buttons multiple times to change state"
android:id="#+id/textView2"
android:layout_below="#+id/imageButton" />
</RelativeLayout>
</ScrollView>
The above code incorporates changes suggested as I understood them or misunderstood them. One suggestion was to remove the images. But I require them.
Remove tools:showIn="#layout/activity_main" and replace the code with below code and also replace cloasing tag </RelativeLayout> with </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="56dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:layout_height="230dp"
android:layout_column="1"
android:background="#mipmap/ic_launcher"
android:contentDescription='android:ContentDescription="#string/desc"'
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView"
android:background="#ffffff"
android:foreground="#05ffffff"
android:foregroundTint="#03ffffff"
android:text="We've been serving good people like you since 1994 with special deals on their travel plans. "
android:textColor="#000000" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/text1"
android:text="Cancun, Chichen Itza." />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText2"
android:text="Holbox, Taxco, Palenque, Acapulco, Ixtapa, Guanajuato,
Cabo San Lucas, Puerto Vallarta, Monterrey, Tenacatita, Mascota" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText3"
android:background="#mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/editText"
android:layout_below="#+id/editText"
android:ems="10"
android:inputType="textEmailAddress"
android:text="thewebmaster#cancunsteve.com" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText3"
android:layout_marginLeft="42dp"
android:layout_marginStart="32dp"
android:ems="10"
android:inputType="phone"
android:text="011 52 998 8873919" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText4"
android:text="be sure to visit us discounts on your hotel bookings" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageButton"
android:text="click buttons multiple times to change state" />
</LinearLayout>
</ScrollView>
I have two buttons (Next and Cancel) in my layout that are crammed to the left side of the screen and it won't allow me to adjust them past the centre. I tried playing around with the attributes of the buttons to fix it, I even considered placing these buttons in a linear layout in order to organize them with no luck.
I've attached my .xml file, I would really appreciate it if someone can point out where I'm going wrong.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<EditText
android:id="#+id/emailAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:text="Email"
android:layout_marginTop="79dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:id="#+id/mobileNum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="Mobile"
android:layout_alignParentStart="true"
android:layout_below="#+id/emailAddress"
android:layout_centerHorizontal="true" />
<EditText
android:id="#+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:text="Password"
android:layout_alignParentStart="true"
android:layout_below="#+id/mobileNum"
android:layout_centerHorizontal="true" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="23dp"
android:layout_below="#+id/password"
android:layout_above="#+id/loginButton"
android:layout_alignEnd="#+id/password">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rider"
android:id="#+id/riderRadioButton"
android:layout_alignTop="#+id/driverRadioButton"
android:layout_toEndOf="#+id/driverRadioButton"
android:layout_alignBottom="#+id/driverRadioButton"
android:checked="false"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Driver"
android:id="#+id/driverRadioButton"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:checked="false"
android:onClick="onRadioButtonClicked" />
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Your email and number are used to send you ride confirmations"
android:id="#+id/messageTextView"
android:layout_below="#+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="79dp"
android:textAlignment="center"
android:textSize="13dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/messageTextView">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:id="#+id/nextButton"
android:layout_marginTop="35dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/cancelButton"
android:layout_marginEnd="85dp"/>
</LinearLayout>
At the time, I didn't have experience with xml files. However, I have been able to fix it now. I removed the LinearLayout which contained the buttons, and played around with some attributes to get it to work.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="daniaghazal.com.hitchhikr.SignUpPage">
<EditText
android:id="#+id/emailAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="Email"
android:layout_marginTop="79dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:id="#+id/mobileNum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="Mobile"
android:layout_alignParentStart="true"
android:layout_below="#+id/emailAddress"
android:layout_centerHorizontal="true" />
<EditText
android:id="#+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="Password"
android:layout_alignParentStart="true"
android:layout_below="#+id/mobileNum"
android:layout_centerHorizontal="true" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="23dp"
android:layout_below="#+id/password"
android:checkedButton="#+id/riderRadioButton"
android:layout_alignBottom="#+id/messageTextView"
android:layout_alignParentEnd="true">
<RadioButton
android:id="#+id/riderRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rider"
android:layout_alignTop="#+id/driverRadioButton"
android:layout_toEndOf="#+id/driverRadioButton"
android:layout_alignBottom="#+id/driverRadioButton"
android:checked="false"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/driverRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Driver"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:checked="false"
android:onClick="onRadioButtonClicked" />
</RadioGroup>
<TextView
android:id="#+id/messageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Your email and number are used to send you ride confirmations"
android:layout_below="#+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="79dp"
android:textAlignment="center"
android:textSize="13dp"/>
<Button
android:id="#+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_marginLeft="75dp"
android:layout_marginTop="20dp"
android:layout_below="#+id/messageTextView"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_marginTop="20dp"
android:layout_below="#+id/radioGroup"
android:layout_toEndOf="#+id/nextButton" />
</RelativeLayout>
Try to set android:gravity attribute of parent layout to center it's content. Something like:
EDIT
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<EditText
android:id="#+id/emailAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:text="Email"
android:layout_marginTop="79dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<EditText
android:id="#+id/mobileNum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="Mobile"
android:layout_alignParentStart="true"
android:layout_below="#+id/emailAddress"
android:layout_centerHorizontal="true"/>
<EditText
android:id="#+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:text="Password"
android:layout_alignParentStart="true"
android:layout_below="#+id/mobileNum"
android:layout_centerHorizontal="true"/>
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="23dp"
android:layout_below="#+id/password"
android:checkedButton="#+id/riderRadioButton"
android:layout_alignBottom="#+id/messageTextView"
android:layout_alignParentEnd="true">
<RadioButton
android:id="#+id/riderRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rider"
android:layout_alignTop="#+id/driverRadioButton"
android:layout_toEndOf="#+id/driverRadioButton"
android:layout_alignBottom="#+id/driverRadioButton"
android:checked="false"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/driverRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Driver"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:checked="false"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Your email and number are used to send you ride confirmations"
android:id="#+id/messageTextView"
android:layout_below="#+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="79dp"
android:textAlignment="center"
android:textSize="13dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/messageTextView"
android:layout_marginTop="20dp"
android:gravity="center_horizontal">
<Button
android:id="#+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"/>
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"/>
</LinearLayout>
</RelativeLayout>
[My Layout]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".Login"
android:background="#drawable/background">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/efield"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/textView_username" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Username :"
android:id="#+id/textView_username"
android:textColor="#FFFFFF"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="10dp"
android:layout_above="#+id/textView_attempt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="right"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Password :"
android:id="#+id/textView_password"
android:textColor="#FFFFFF"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_above="#+id/textView_attempt_count"
android:layout_alignRight="#id/editText_pass"
android:layout_alignEnd="#id/editText_pass"
android:gravity="right" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText_user"
android:text="Name"
android:textColor="#FFFFFF"
android:layout_alignTop="#+id/textView_username"
android:layout_alignRight="#+id/imageView"
android:layout_alignEnd="#+id/imageView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/editText_password"
android:text="Password"
android:textColor="#FFFFFF"
android:layout_alignTop="#+id/textView_password"
android:layout_alignLeft="#id/textView_password"
android:layout_alignStart="#+id/editText_user" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attempts :"
android:id="#+id/textView_attempt"
android:textColor="#FFFFFF"
android:paddingTop="40dp"
android:layout_centerVertical="true"
android:layout_alignRight="#+id/textView_username"
android:layout_alignEnd="#+id/textView_username" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView_attempt_count"
android:layout_alignBottom="#+id/textView_attempt"
android:layout_alignLeft="#+id/editText_password"
android:layout_alignStart="#+id/editText_password"
android:textColor="#FFFFFF"/>
<Button
android:layout_width="160dp"
android:layout_height="40dp"
android:text="Login"
android:id="#+id/button_login"
android:background="#drawable/statelistdrawable"
android:textColor="#drawable/txco"
android:layout_above="#+id/textView_time"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textView_time"
android:gravity="center"
android:textColor="#FFFFFF"
android:layout_above="#+id/button_FP"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="Forgot Password"
android:id="#+id/button_FP"
android:background="#android:color/transparent"
android:textColor="#drawable/tbutton"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
My Layout 1
Want to remove space between "Username" textview and "Name" edittext in Landscape. My layout is looking proper in portrait but gives space in between textview and edittext in landscape.
My XML Preview design before executing android studio.
After Executing android studio design is showing old design, I changed EditText name but still showing the same name and also added new button that also not reflecting after run my android app.
Below is my XML design:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.cnkonline.demo2.MainActivity"
tools:showIn="#layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Email"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Password"
android:id="#+id/textView2"
android:layout_below="#+id/textView"
android:layout_alignParentStart="true"
android:layout_marginTop="42dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Mobile"
android:id="#+id/textView3"
android:layout_below="#+id/textView2"
android:layout_alignParentStart="true"
android:layout_marginTop="42dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="#+id/button"
android:layout_toEndOf="#+id/textView2"
android:layout_marginTop="77dp"
android:layout_alignTop="#+id/textView3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_gravity="center"
android:layout_below="#+id/textView"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:layout_gravity="center"
android:layout_below="#+id/textView2"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText3"
android:layout_gravity="center"
android:layout_below="#+id/textView3"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="#+id/button2"
android:layout_below="#+id/button"
android:layout_alignEnd="#+id/button" />