I am developing an android application. On the preview the view is presanting the way I have set it but when I run it on a device I am seeing spaces on it right and left side. Screen shots are attached for the better understanding of the problem.
Below is the code of my layout.
<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"
tools:context="------"
>
<!-- TODO: Update blank fragment layout -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scrollView"
android:scrollbars="none"
android:layout_gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/screen_background">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/telephone_number"
android:id="@+id/telephonNumberTextView"
android:phoneNumber="false"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/phoneNumberEditText"
android:layout_weight="1"
android:clickable="true"
android:singleLine="true"
android:background="@drawable/edittext"
android:paddingLeft="4dp"
android:textAlignment="textStart" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/telephone_extension"
android:id="@+id/telephoneExtensionTextView"
android:layout_marginTop="10dp"
android:layout_gravity="left|center_vertical"
android:textColor="@android:color/white"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/telephoneExtensionEditText"
android:background="@drawable/edittext"
android:singleLine="true"
android:paddingLeft="4dp"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/email_id"
android:id="@+id/emailIdTextView"
android:layout_gravity="left|center_vertical"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/emailIdEditText"
android:layout_gravity="center_vertical"
android:singleLine="true"
android:layout_weight="1"
android:background="@drawable/edittext"
android:paddingLeft="4dp"
android:layout_margin="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/problem_type"
android:id="@+id/problemTypeTextView"
android:layout_gravity="left|center_vertical"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:text="@string/fetch_problem_types"
android:id="@+id/button"
android:background="@drawable/buttonback"
android:textColor="@android:color/white"
android:layout_gravity="center"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/location"
android:id="@+id/locationTextView"
android:layout_gravity="left|center_vertical"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPostalAddress"
android:ems="10"
android:id="@+id/locationEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="@drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/brief_desc"
android:id="@+id/briefDescTextView"
android:layout_gravity="left|center_vertical"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/briefDescEditText"
android:singleLine="true"
android:layout_gravity="bottom"
android:background="@drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/doc_desc"
android:id="@+id/docDescTextView"
android:layout_gravity="left|center_vertical"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/docDescEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="@drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/approval_memo"
android:id="@+id/approvalMemoTextView"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="10dp"
android:textColor="@android:color/white"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/approvalMemoEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="@drawable/edittext"
android:paddingLeft="4dp"
android:layout_weight="1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/requester_Name"
android:id="@+id/requesterNameTextView"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="10dp"
android:textColor="@android:color/white"
android:layout_marginBottom="5dp"
android:paddingLeft="2dp"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/requesterNameEditText"
android:layout_gravity="bottom"
android:singleLine="true"
android:background="@drawable/edittext"
android:layout_weight="1"
android:layout_marginBottom="5dp"
android:paddingLeft="4dp"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:text="@string/submit_button_title"
android:id="@+id/submitButton"
android:layout_gravity="center_vertical"
android:background="@drawable/buttonback"
android:textColor="@android:color/white"
android:layout_marginTop="10dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="5dp"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
The problem (most probably) lies in the top level XML. I assume you posted only the content.xml
which is included my activity_main.xml
, because I can't see the Floating Action Button.
I guess you used the build-in generator to create layouts for you and edited the content.xml
one. The paddings are defined inside the activity_main.xml
one. Delete them and you are good to go.
Remove layout android:layout_margin="5dp" in Email Id EditText
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/emailIdEditText"
android:layout_gravity="center_vertical"
android:singleLine="true"
android:layout_weight="1"
android:background="@drawable/edittext"
android:paddingLeft="4dp" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.