Edittext in Android not being full size - android

So I have a edittext in Android.
Here is the declaration:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:text="Type in here!"
android:inputType="text"
android:backgroundTint="#ffffffff"
android:autoText="false" />
However I can only type text in the lower half of the textbox:
As you can see in the following image the prompt text appears 1/2 way down the textbox:
And I can only type text 1/2 way down the textbox:
Why is am I only allowed to type in 1/2 of my textbox even though in the design view it shows that the textbox is covering the entire screen.

Remove this code edittext.
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"

Add some lines as I have mentioned here.
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:text="Type in here!"
android:inputType="text"
android:backgroundTint="#ffffffff"
android:autoText="false"
android:scrollbars="vertical"
android:gravity="top|left
android:inputType="textMultiLine" />

The solution turned out to be easy, simply add the line:
android:gravity="top|left

Related

Edit text overlaps each other

I am creating an android application in which i am collecting user's some messages.But i am getting some issues such as following..
I have added 3 edit text in alert dialog..the third edit text box having multi line textbox so whenever i am adding multiple lines its getting overlapped to above two edit text
here is the snapshot of the error
Here Is Layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<ScrollView
android:layout_width="245dp"
android:layout_height="245dp"
android:layout_weight="0.40"
android:layout_gravity="center_horizontal">
<RelativeLayout
android:layout_width="245dp"
android:layout_height="200dp">
<EditText
android:layout_width="235dp"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText6"
android:layout_gravity="center_horizontal"
android:hint="Your Email Id"
android:layout_alignBaseline="#+id/editText5"
android:layout_alignBottom="#+id/editText5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="240dp"
android:layout_height="wrap_content"
android:id="#+id/editText4"
android:layout_gravity="center_horizontal"
android:hint="Title"
android:singleLine="true"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="236dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText5"
android:hint="Description"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /></RelativeLayout></ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="#+id/button10"
android:layout_gravity="center_horizontal" />
</LinearLayout>
Reason for your issue is android:inputType="textMultiLine" pushes content when there is a new line!
You can use android:maxLines="1" for your EditText [any way this will be useful for you since you have used android:singleLine="true" with is kind of dipricated ]
Ps: Hard coding android:maxLength will not solve your issue since screens can be in different sizes which makes you hard to decide how many lines you keep!
Also you can use android:maxHeight="xdp" for the editText view, then the limit won't exeed!
You should use
android:maxLength="4"
row numbers you want to fix for your edit text
Use LinearLayout with vertical orientation instead of RelativeLayout.
If u want to use RelativeLayout, then set layout_below attribute of RelativeLayout.
You need to set android:maxLines="4". Set your max lines to solve this issue.
<EditText
android:id="#+id/editText4"
android:maxLines="4"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Title"
android:layout_alignParentStart="true" />
You can use android:layout_below and android:layout_marginTop in your EditText views and keep distance between your views.
Example :
<EditText
android:layout_width="236dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText5"
android:hint="Description"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText4"
android:layout_marginTop="20dp"/>

Android EditText text is not vertically centered

I have search bar that defines EditBox like
<EditText
android:id="#+id/search_editbox"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/search_execute_imageview"
android:layout_toRightOf="#id/layout_back_logo"
android:gravity="left"
android:hint="#string/search_hint"
android:maxLength="20"
android:textCursorDrawable="#null"
android:drawableRight="#drawable/abc_ic_clear_holo_light"
android:background="#drawable/rounded_edittext_states"
android:padding="5dip"
android:singleLine="true"
android:textSize="#dimen/main_text_size" />
Despite android:layout_centerVertical="true" the text is not in the middle, but closer to upper side.
Use
android:gravity="left|center_vertical"
The correct answer is right but it is recommended to use:
android:gravity="start|center_vertical" instead of ("left") to avoid formatting errors.
try this:
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:ems="10"
android:gravity="left|center_horizontal"
android:textAlignment="center" >
</EditText>
just change your gravity value to "left center align".
android:gravity:"left|center"

EditText and AutoCompleteTextView text starts not on same position

I've a EditText and a AutoCompleteTextView and the text starts not on the same position which looks a bit strange.
I'm using appcompat v7 and I don't know if it's possible to fix this.
The line in the bottom is also different (so so bad as the text begin)
I also tried to style it like appcompat's EditText, but that doesn't look like that.
Code
<EditText
android:id="#+id/input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignEnd="#+id/button_berechnen"
android:layout_alignRight="#+id/button_berechnen"
android:ellipsize="end"
android:gravity="start"
android:hint="#string/input_ipAdresse"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:paddingStart="#dimen/padding_small"
android:paddingEnd="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium" >
<requestFocus android:layout_width="match_parent" />
</EditText>
<AutoCompleteTextView
android:id="#+id/input_snm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_below="#+id/input_ipAdresse"
android:ellipsize="end"
android:gravity="start"
android:imeActionLabel="#string/Button_berechnen"
android:imeOptions="actionDone|flagNoExtractUi"
android:inputType="phone"
android:paddingStart="#dimen/padding_small"
android:paddingEnd="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium" />

How to fix this text input in relative layout

I have XML like this :
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/button1" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/button1"
android:layout_toLeftOf="#+id/button1"
android:ems="10"
android:inputType="textMultiLine" />
</RelativeLayout>
And the view like this :
How can I fix that?
The problem is that you are using the android:ems attribute, which sets an exact width to the TextView (measured in EMs).
This overrides android:layout_width="wrap_content", and thus the text in the EditText overflows.
I'm guessing what you actually wanted was to set the size of the text, which should be done using android:textSize and SP units.

TextEdit setText("some text here") changes my text color to white

When I call usernameField.setText(myEmail) it changes the text to white. The email address is still in there but it seems to be hidden for some reason. What could be causing this?
usernameField = (EditText) findViewById(R.id.usernameTextField);
usernameField.setText(myEmail);
usernameField.setTextColor(color.black);
XML for whole view:
<EditText
android:id="#+id/usernameTextField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:ems="10"
android:inputType="textPersonName"
android:text="#string/emailHint"
android:textColor="#color/black"
android:textColorHint="#color/black"
android:textColorLink="#color/white" />
<EditText
android:id="#+id/passwordtextField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/usernameTextField"
android:layout_below="#+id/usernameTextField"
android:ems="10"
android:inputType="textPassword|textPersonName"
android:text="#string/emailHint"
android:textColor="#color/black"
android:textColorHint="#color/black"
android:textColorLink="#color/black" >
<requestFocus />
</EditText>
<ImageButton
android:id="#+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#color/black"
android:src="#drawable/wallet_menu_profile"
android:contentDescription="#string/loginHint"
/>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<TextView
android:id="#+id/statusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/loginButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="57dp"
android:text="#string/prowdstatus"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/grey" />
you use
android:textColorLink="#color/white"
change this color for black or other, or remove this line from xml beacuse if you set the email in editText android can change color for white and create link. (not sure if this happen by default, but if you add
android:autoLink="for example email", and if the text will be hosted email - text changed color automatically and created link.
I hope this will help you.
I believe this is the possible culprit: android:textColorLink="#color/white"
Change it to black or remove it and you're set.

Categories

Resources