I'm really new to android and would appreciate any help from you.
I have a screen with different templates for two kind of products. Each template is a separate xml file where I place a bunch of controls. Every control has it's own exact place in the screen which I define with margins.
The problem is I don't know how long is going to be a text in the upper TextView. If there is a one line everything looks fine, but a few lines destroy it.
Is there any way to stretch upper textview and at the same time keep all the rest controls relative to this textview?
The code is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/regBackground"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/regBackground" >
<TextView
android:id="#+id/txtProductNameScreenD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="10dp"
android:layout_marginRight="18dp"
android:layout_marginTop="10dp"
android:text="#string/empty"
android:textColor="#color/_black"
android:textSize="16sp"
android:textStyle="bold"
android:lines="1"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true" >
</TextView>
<ImageView
android:id="#+id/imgProductBcgD"
android:layout_width="300dp"
android:layout_height="263dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:src="#drawable/frame_product_screen" >
</ImageView>
<ImageView
android:id="#+id/imgProductScreenD"
android:layout_width="250dp"
android:layout_height="260dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="42dp"
android:background="#color/_white" >
</ImageView>
<ImageView
android:id="#+id/imgProductScreendiscD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center"
android:layout_marginTop="205dp"
android:src="#drawable/discount_bkg_product_screen" >
</ImageView>
<TextView
android:id="#+id/txtProdScreenPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:layout_marginRight="45dp"
android:layout_marginTop="220dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/empty"
android:textColor="#color/_black"
android:textSize="18sp" >
</TextView>
<TextView
android:id="#+id/txtPriceShekelD1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:layout_marginRight="80dp"
android:layout_marginTop="230dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/shekel_symbol"
android:textColor="#color/_gray"
android:textSize="10sp" />
<TextView
android:id="#+id/txtBeforeDiscD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:layout_marginRight="25dp"
android:layout_marginTop="237dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/before_discount"
android:textColor="#color/_gray"
android:textSize="10sp" />
<TextView
android:id="#+id/txtProdScreenDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:layout_marginRight="140dp"
android:layout_marginTop="220dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/empty"
android:textColor="#color/_orange"
android:textSize="18sp" >
</TextView>
<TextView
android:id="#+id/txtDiscountD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:layout_marginRight="145dp"
android:layout_marginTop="237dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/bonus"
android:textColor="#color/_gray"
android:textSize="10sp" />
<TextView
android:id="#+id/txtProdScreenDiscountPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|top"
android:layout_marginLeft="45dp"
android:layout_marginTop="220dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/empty"
android:textColor="#color/_black"
android:textSize="18sp" >
</TextView>
<TextView
android:id="#+id/txtPriceShekelD2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|top"
android:layout_marginLeft="30dp"
android:layout_marginTop="230dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/shekel_symbol"
android:textColor="#color/_gray"
android:textSize="10sp" />
<TextView
android:id="#+id/txtAfterDiscD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|top"
android:layout_marginLeft="30dp"
android:layout_marginTop="237dp"
android:ellipsize="end"
android:lines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="#string/after_discount"
android:textColor="#color/_gray"
android:textSize="10sp" />
<Button
android:id="#+id/btnShareFacebookD"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="255dp"
android:background="#drawable/facebook_button_product_screen" >
</Button>
<TextView
android:id="#+id/txtDatePSDiscD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_horizontal"
android:layout_marginRight="90dp"
android:layout_marginTop="315dp"
android:text="#string/exp_date"
android:textColor="#color/_gray"
android:textSize="14sp" >
</TextView>
<TextView
android:id="#+id/txtDateProductScreenD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_horizontal"
android:layout_marginLeft="90dp"
android:layout_marginTop="315dp"
android:text="#string/empty"
android:textColor="#color/_blue"
android:textSize="14sp" >
</TextView>
<ImageView
android:id="#+id/imgSeparatorProductScreenD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="345dp"
android:src="#drawable/separator_product_screen" >
</ImageView>
<TextView
android:id="#+id/txtDescriptionProductScreenD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="355dp"
android:inputType="textMultiLine"
android:text="#string/empty"
android:textColor="#color/_black"
android:textSize="12sp" >
</TextView>
</FrameLayout>
</LinearLayout>
I can constrain the text to be just single line with the following parameter
android:singleLine = "true"
Moreover, you can fade the edge of it, just to make it look better
android:fadeScrollbars = "true"
If you want the users to be able to read the whole text you can add a scrolling effect.
http://developer.android.com/reference/android/widget/TextView.html
Related
I have to show two text views in a side by side layout. In addition I have to do this in 3 columns but I have to put them side by side. I did it one under the other but I couldn't side by side them all together unfortunately. What I want to do is: I want to bring these together, but it must be in a layout. I would really appreciate it if you show me how I can do this in the relative layout.
Screenshot
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/calismalartext"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="#font/roboto"
android:gravity="center"
android:lines="1"
android:padding="2dp"
android:text="Çalışmalar"
android:textColor="#color/colorBlack"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/prof_Works"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:layout_below="#+id/calismalartext"
android:gravity="center"
android:lines="1"
android:padding="1dp"
android:text=""
android:background="#drawable/rounded_rectangle_orange"
android:textColor="#color/colorBlack"
android:textSize="13sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/takiptext"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="#font/roboto"
android:gravity="center"
android:lines="1"
android:padding="2dp"
android:text="Takip"
android:textColor="#color/colorBlack"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/prof_Follows"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="#drawable/rounded_rectangle_orange"
android:ellipsize="end"
android:gravity="center"
android:layout_below="#+id/takiptext"
android:lines="1"
android:padding="1dp"
android:text=""
android:textColor="#color/colorBlack"
android:textSize="13sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/takipcitext"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto"
android:gravity="center"
android:lines="1"
android:padding="2dp"
android:text="Takipçi"
android:textColor="#color/colorBlack"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/prof_Followers"
android:layout_width="100dp"
android:background="#drawable/rounded_rectangle_orange"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="1"
android:layout_below="#+id/takipcitext"
android:padding="1dp"
android:text=""
android:textColor="#color/colorBlack"
android:textSize="13sp" />
</RelativeLayout>
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" />
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 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>