small problem here:
This is my code of the layout in question:
<LinearLayout
android:orientation="horizontal"
android:layout_weight="100"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_gravity="center">
<EditText
android:background="#00000000"
android:singleLine="true"
android:maxLength="2"
android:inputType="number"
android:gravity="bottom"
android:hint="00"
android:textColorHint="#2f8677"
android:textColor="#2f8677"
android:textSize="40sp"
android:id="#+id/txtMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:gravity="top"
android:layout_gravity="top"
android:text=":"
android:textSize="40dp"
android:textColor="#2f8677"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:background="#00000000"
android:singleLine="true"
android:maxLength="2"
android:inputType="number"
android:gravity="bottom"
android:hint="00"
android:textColorHint="#2f8677"
android:textColor="#2f8677"
android:textSize="40sp"
android:id="#+id/txtSeconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_gravity="center"
android:text=":"
android:textSize="40dp"
android:textColor="#2f8677"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:background="#00000000"
android:singleLine="true"
android:maxLength="2"
android:inputType="number"
android:gravity="bottom"
android:hint="00"
android:textColorHint="#2f8677"
android:textColor="#2f8677"
android:textSize="40sp"
android:id="#+id/txtTimerMicroSeconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
This is the result:
Why are the ":" sitting on the bottom and the EditTexts are on top? Both are (obviously) supposed to be on the same hight :(
Another little thing: See that little bar to the left of the first EditText? It is there because this is an edit text and you can "type" things into it. But I don't want it to show- How do I get this to go away?
I see some issues in your android:gravity, you can use android:gravity="center_vertical" to align your widgets with each other.
See the result here:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="100"
android:gravity="center_horizontal"
android:orientation="horizontal">
<EditText
android:id="#+id/txtMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:gravity="center_vertical"
android:hint="00"
android:inputType="number"
android:maxLength="2"
android:singleLine="true"
android:textColor="#2f8677"
android:textColorHint="#2f8677"
android:textSize="40sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:gravity="center_vertical"
android:text=":"
android:textColor="#2f8677"
android:textSize="40dp" />
<EditText
android:id="#+id/txtSeconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:gravity="center_vertical"
android:hint="00"
android:inputType="number"
android:maxLength="2"
android:singleLine="true"
android:textColor="#2f8677"
android:textColorHint="#2f8677"
android:textSize="40sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text=":"
android:textColor="#2f8677"
android:textSize="40dp" />
<EditText
android:id="#+id/txtTimerMicroSeconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:gravity="center_vertical"
android:hint="00"
android:inputType="number"
android:maxLength="2"
android:singleLine="true"
android:textColor="#2f8677"
android:textColorHint="#2f8677"
android:textSize="40sp" />
</LinearLayout>
Use below code:
I have removed layout_top from textview for alignment.
And you may use android:cursorVisible="false" to hide edittext cursor.
If you do not want to allow editing, then use textview instead of Edittext
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
android:gravity="center"
android:layout_gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android">
<EditText
android:background="#00000000"
android:singleLine="true"
android:maxLength="2"
android:inputType="number"
android:gravity="bottom"
android:hint="00"
android:cursorVisible="false"
android:textColorHint="#2f8677"
android:textColor="#2f8677"
android:textSize="40sp"
android:id="#+id/txtMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:gravity="top"
android:text=":"
android:textSize="40dp"
android:textColor="#2f8677"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:background="#00000000"
android:singleLine="true"
android:maxLength="2"
android:inputType="number"
android:gravity="bottom"
android:hint="00"
android:cursorVisible="false"
android:textColorHint="#2f8677"
android:textColor="#2f8677"
android:textSize="40sp"
android:id="#+id/txtSeconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_gravity="center"
android:text=":"
android:textSize="40dp"
android:cursorVisible="false"
android:textColor="#2f8677"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:background="#00000000"
android:singleLine="true"
android:maxLength="2"
android:inputType="number"
android:gravity="bottom"
android:hint="00"
android:textColorHint="#2f8677"
android:textColor="#2f8677"
android:textSize="40sp"
android:id="#+id/txtTimerMicroSeconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Related
I followed someone example on having a relative layout with a scrollview. I did exactly it and my page still won't scroll. Am I missing out something? Or must I change it to a linear layout to make it work? Still new to Android Studio here.
Any help will be much appreciated. Randomly adding words so I can post this.
activity_info.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:layout_width="fill_parent"
android:layout_height="900dp"
tools:context="mapp.com.sg.receiptscanner.Info">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="900dp"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="900dp"
>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/editText5"
android:layout_marginTop="13dp"
android:text="Name of Product:"
android:textColor="#android:color/black"
android:textSize="18sp"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="16dp" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText6"
android:layout_below="#+id/editText5"
android:layout_marginTop="16dp"
android:text="Company:"
android:textColor="#android:color/black"
android:textSize="18sp"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="16dp" />
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText5"
android:layout_below="#+id/textView9"
android:ems="10"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="61dp" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView8"
android:layout_marginStart="13dp"
android:ems="10"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="61dp" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText6"
android:layout_below="#+id/editText6"
android:layout_marginTop="22dp"
android:textSize="18sp" />
<EditText
android:id="#+id/editText8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView11"
android:layout_below="#+id/textView12"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText6"
android:layout_marginTop="11dp"
android:layout_toEndOf="#+id/textView11"
android:text="Receipt Number:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText8"
android:layout_below="#+id/editText8"
android:layout_marginTop="19dp"
android:text="Start Date of Warranty:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="12dp"
android:layout_marginTop="273dp"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText10"
android:layout_alignTop="#+id/editText10"
android:layout_marginTop="60dp"
android:text="Expiry Date of Warranty:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView14"
android:layout_below="#+id/textView14"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText11"
android:layout_below="#+id/editText11"
android:layout_marginTop="14dp"
android:text="Bought from:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView15"
android:layout_below="#+id/textView15"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText12"
android:layout_below="#+id/editText10"
android:layout_marginTop="177dp"
android:text="Warranty Site:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView16"
android:layout_below="#+id/textView16"
android:ems="10"
android:inputType="textPersonName" />
</RelativeLayout>
</ScrollView>
We can able to scroll the view only when the items in the scroll view exits the visibility. I check your code it happens for your layout too. For checking add few more item in that scroll view, It will start scroll
And one more thing instead of setting some constant value set android:layout_height="wrap_content"
This should work:
<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"
tools:context="mapp.com.sg.receiptscanner.Info">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
always use this
android:layout_width="match_parent"
android:layout_height="wrap_content"
for scrollview and its only child.
I have a linearlayout with a textview, and edittext. How do I center the text within edittext. It appears to be drawn to the bottom as shown below.I want it to be consistent with the baseline similar to that of the textview to its left.
The layout code is as below:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
>
<TextView
android:layout_width="75dp"
android:layout_height="30dp"
android:ems="10"
android:textAlignment="center"
android:text="NAME"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:singleLine="true"
android:id="#+id/tv_name"
android:background="#drawable/orange_left_rounded_corner"
/>
<EditText
android:layout_width="125dp"
android:layout_height="30dp"
android:ems="10"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:text=""
android:layout_gravity="right"
android:gravity="center_horizontal"
android:textColor="#000000"
android:textSize="16sp"
android:singleLine="true"
android:id="#+id/et_name"
android:background="#drawable/orange_right_rounded_corner"
/>
</LinearLayout>
Use android:gravity="center" to have the input be centered
Just do that
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
>
<TextView
android:layout_width="75dp"
android:layout_height="30dp"
android:ems="10"
android:textAlignment="center"
android:text="NAME"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:singleLine="true"
android:id="#+id/tv_name"
android:background="#drawable/orange_left_rounded_corner"
android:gravity="center_vertical"
/>
<EditText
android:layout_width="125dp"
android:layout_height="30dp"
android:ems="10"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:text=""
android:layout_gravity="right"
android:gravity="center_horizontal"
android:textColor="#000000"
android:textSize="16sp"
android:singleLine="true"
android:id="#+id/et_name"
android:background="#drawable/orange_right_rounded_corner"
/>
Try with 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="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_name"
android:layout_width="75dp"
android:layout_height="30dp"
android:background="#drawable/orange_left_rounded_corner"
android:ems="10"
android:gravity="center_vertical"
android:singleLine="true"
android:text="NAME"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<EditText
android:id="#+id/et_name"
android:layout_width="125dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:background="#drawable/orange_right_rounded_corner"
android:ems="10"
android:gravity="center_horizontal"
android:singleLine="true"
android:text=""
android:textAlignment="center"
android:textColor="#000000"
android:textSize="16sp" />
</LinearLayout>
I have 5 horizontal linear layout is there. I aligned three edittext in a single linear layout. And I applied the weight field property 1 for all the editext. But in 1st and 3rd linear layout working perfectly with the property. Others are not working properly. Again in 5th horizontal linear layout have one spinner view, it was also creating the same problem. Then 4th line one addition linear layout available inside the horizontal layout, with one edittext and one imageview. It is also not fixing properly with weight property. I put layout code below.
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/yellow" />
<TextView
android:id="#+id/sign_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Sign Up" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/f_name"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="20"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPersonName"
android:layout_marginRight="20dp"
android:hint="First Name"
android:background="#drawable/edittext_yellow_singleline" >
</EditText>
<EditText
android:id="#+id/l_name"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="20"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPersonName"
android:layout_marginRight="20dp"
android:hint="Last Name"
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/uname"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="20"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPersonName"
android:hint="Username *"
android:background="#drawable/edittext_yellow_singleline" />
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout//this layout creating alignment issue. if I put extra space in hint nearly it was getting good view. But different screens wont work
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/phone"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="12"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="phone"
android:layout_marginRight="20dp"
android:hint="Phone"
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/plan_id"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPostalAddress"
android:layout_marginRight="20dp"
android:hint="Member Plan ID"
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/pass"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="20"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPassword"
android:hint="Password *"
android:background="#drawable/edittext_yellow_singleline" />
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="50"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPostalAddress"
android:layout_marginRight="20dp"
android:hint="Address"
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/mobile"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="10"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="phone"
android:layout_marginRight="20dp"
android:hint="Mobile * "
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="30"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textEmailAddress"
android:hint="Email * "
android:background="#drawable/edittext_yellow_singleline" />
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/city"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="30"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPostalAddress"
android:layout_marginRight="20dp"
android:hint="City"
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/state"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="30"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPostalAddress"
android:layout_marginRight="20dp"
android:hint="State"
android:background="#drawable/edittext_yellow_singleline" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">//tried this not worked
<EditText
android:id="#+id/dob"
android:layout_width="265dp"
android:layout_height="40dp"
android:maxLength="10"
android:textSize="18dp"
android:inputType="date"
android:hint="Date of Birth"
android:background="#drawable/edittext_yellow_singleline" />
<ImageButton
android:id="#+id/img_dob"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/cal" />
</LinearLayout>
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/country"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="textPostalAddress"
android:layout_marginRight="20dp"
android:hint="Country"
android:background="#drawable/edittext_yellow_singleline" />
<EditText
android:id="#+id/zipcode"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:maxLength="6"
android:textSize="18dp"
android:layout_weight="1"
android:inputType="number"
android:layout_marginRight="20dp"
android:hint="Zipcode "
android:background="#drawable/edittext_yellow_singleline" />
<Spinner
android:id="#+id/gender"
android:layout_width="305dp"//finally hard coded but it wont work for multiple screens
android:layout_height="40dp"
/>
</LinearLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="30dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/ok"
android:layout_width="100dp"
android:layout_height="40dp"
android:gravity="center"
android:textSize="20dp"
android:text="Done"
android:background="#drawable/login_button_shape" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
If it won't work means, will the table layout give solution for this?
If I reduce the text inside the hint then also it was working fine in 2nd line. If I provide space for keeping same text length in with other edittext field which contains low text also not worked.
All your EditText should have:
android:layout_width="0dp"
And all LinearLayout should have:
android:weightsum="3"
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" />
I am working on an Android application in which I am using edit text. When I put long text in it, it increase the size of the edit text. I having already given "wrap_content" on width and limit the number of lines and 'ems' but it won't work.
When I put long text or short text it increases or decreases the size of edit text. I have post the XML code and snapshot of my problem.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/fname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" First Name:"
android:textColor="#color/Black"
android:textSize="12sp" />
<EditText
android:id="#+id/fnametxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/Beige"
android:enabled="false"
android:lines="1"
android:ems="15"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="ufyufgiuhjlkh"
android:textColor="#color/Black"
android:textSize="12sp" />
</LinearLayout>
Just fix the width size of textview :
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/fname"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text=" First Name:"
android:textColor="#color/Black"
android:textSize="12sp" />
<EditText
android:id="#+id/fnametxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/Beige"
android:enabled="false"
android:lines="1"
android:ems="15"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="ufyufgiuhjlkh"
android:textColor="#color/Black"
android:textSize="12sp" />
</LinearLayout>
Use Below Code it Works fine:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/fname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" First Name:"
android:textColor="#color/Black"
android:textSize="12sp"
android:singleLine="true"/>
<EditText
android:id="#+id/fnametxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/Beige"
android:enabled="false"
android:lines="1"
android:ems="15"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="ufyufgiuhjlkh"
android:textColor="#color/Black"
android:textSize="12sp" />
</LinearLayout>
try this..
by giving width it makes design compatibility complex
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text=" First Name:"
android:textColor="#android:color/black"
android:textSize="12sp"
android:layout_weight="1" />
<EditText
android:id="#+id/fnametxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:layout_weight="3"
android:ems="15"
android:enabled="false"
android:lines="1"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="ufyufgiuhjlkh"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>