Android Edittext width automatically changed when input large text - android

i have edittext and when i input some text width automatically Increased. this is a my edit text xml code
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<EditText
android:id="#+id/namefild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/edittextbackground"
android:hint="Name"
android:paddingLeft="15dp"
android:textColorHint="#e2e0e0" />
</RelativeLayout>
how i can solve my problem? i don't need to change edittext 's width .if anyone knows solution please help me

try this property android:layout_width="0dp"

its because the width of EditText is wrap_content. Try using fixed width or match_parent. It should work.

Related

android 8.0 EditText hint content is not in the middle

When the EditText not gets the focus, the hint content is not in the middle. Why is this happening? Who can help me?
Less than 7.0 its ok
in the 7.1 8.0 it unable to display normally
this is my xml code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="90px">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30px"
android:background="#color/c_dbdbdb"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="30px"
android:text="年龄"
android:textColor="#color/c_666666"
android:textSize="32px"/>
<EditText
android:id="#+id/et_new_appointment_age"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="230px"
android:background="#null"
android:gravity="center_vertical"
android:hint="请输入年龄"
android:inputType="number"
android:minWidth="200px"
android:textColor="#color/c_333333"
android:textColorHint="#color/c_999999"
android:textSize="32px"/>
</RelativeLayout>
Define your edit text ellipsize as start and try I think it will help you.
android:ellipsize="start"
put editText with width and height as wrap content and use
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
inside edit text. it will work.

layout_alignBottom aligns center instead of bottom

I'm trying to get the bottom of my TextView and EditText to line up (perhaps not to the pixel, but close) inside of a RelativeLayout. But layout_alignBottom seems to line up their center line instead of their bottom:
I tried layout_alignBaseline also, but the result was that the EditText does not display on the screen. I also made various efforts at adjusting padding, but it didn't change anything. This seems like it should be easy and a common issue, but I couldn't find anything Googling. Any help would be greatly appreciated.
Thanks.
<TextView
android:id="#+id/firstNameLabel"
android:layout_marginTop="20dp"
android:layout_marginRight="24dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Name" />
<EditText
android:layout_toRightOf="#+id/firstNameLabel"
android:layout_alignBottom="#+id/firstNameLabel"
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Try this.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/firstNameLabel"
android:layout_marginRight="24dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="First Name"
android:textSize="20sp"/>
<EditText
android:layout_toRightOf="#+id/firstNameLabel"
android:layout_alignParentBottom="true"
android:id="#+id/firstName"
android:hint="YO BABY"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
Hope this helps.
Remove margin top from code and check
What's causing this is the EditText being bigger than the textview. Check your layout that contains both and set the gravity to "center" or "center_vertical".
Edit: If you're using RelativeLayout, you should probably use "layout_centerVertical" or "layout_centerInParent" instead

My Edittext getting extended while typing the text

My Edittext its getting extend automatically while typing the text,Dont know what mistake i have done, please check my screen shot for exactly what my issue is, help me to find a solution. Thanks in advance.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<EditText
android:id="#+id/oldpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selectdate"
android:ems="10"
android:hint="#string/oldpass"
android:inputType="textPassword"
android:paddingLeft="5dip" >
</EditText>
</LinearLayout>
</LinearLayout>
check my screen shot for how its extend while typing
your height and weight are Wrap_content as it adjust upon the length of the text you given
change that to fixed dp length
android:layout_width="150dp"
android:layout_height="wrap_content"
It is due to this layout definition: android:layout_width="wrap_content"
You're basically telling that your EditText should fit the content. That means it will have a default size, but once you're typing in it and making it wider, it will extend according to the text it has inside.
You probably want to use android:layout_width="match_parent" to fit it to the screen, or play around with android:layout_weight to make it proportional to other layout items.
Set WEIGHT property of your edittext it will not extended.
android:layout_width="0dp"
android:layout_weight="1"
Try this
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center" >
<EditText
android:id="#+id/oldpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selectdate"
android:ems="10"
android:hint="#string/oldpass"
android:inputType="textPassword"
android:paddingLeft="5dip" >
</EditText>
</LinearLayout>
I believe your issue is you are setting the layout_width of the EditText as wrap_content

Android layout : imageview is moving along with edittext

Hi, I have a image view and edit text as follows
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="400dp"
android:background="#eeeff4" >
<TextView
android:id="#+id/btextview"
android:layout_width="280px"
android:layout_height="33dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#3B5999"
android:ellipsize="start"
android:gravity="left|center_vertical"
android:paddingLeft="40dp"
android:text="post it"
android:textSize="17sp" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/username"
android:layout_alignParentLeft="true"
android:background="#3B5999"
android:paddingRight="5dp"
android:src="#drawable/book" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/bedittext"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/imageView2"
android:layout_alignTop="#+id/bedittext"
android:src="#drawable/myfb"
android:layout_marginLeft="6dp" />
<EditText
android:id="#+id/bedittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/btextview"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/imageView1"
android:ems="10"
android:hint="say something about this"
android:inputType="textMultiLine"
android:scrollHorizontally="true" >
</EditText>
</RelativeLayout>
when I type in the edittextview multiple line the imageveiw1 also moving along with the edit text, I want the image to be fixed in that position and only the edit text should expand, also how can I make the edittext to get scrolling after 3 lines.
Any suggestion is appreciated.
I type in the edittextview multiple line the imageveiw1 also moving along with the edit text
because you are setting layout_width="wrap_content" to that edit text, so that if you type one character then image shows next to that char, if you type 2nd char then it moves.. ok? to avoid that you can set fixed with or match_parent to that edittext.
2 . how can I make the edittext to get scrolling after 3 lines
just set fixed height to show only three lines and move that edit text into scroll view(this height and width should wrap_content).
You can set the max height of the EditText (android:maxHeight), and set the layout_height of the EditText to wrap_content so it expand till max height

How can I change the height of a EditText and a Button?

I have this EditText and Button, and I have to reduce its height. I try with android:height="10px" but it doesn't work. Btw android:width="180px" works OK, then I don't know why I can't adjust the height.
Here is the code:
<EditText
android:id="#+id/Movile"
android:layout_alignBaseline="#+id/MovileLabel"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="180px"
android:height="10px"/>
<Button
android:id="#+id/inviteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/invite"
android:width="100px"
android:height="5px"
android:layout_marginLeft="40dip"/>
Instead of setting values to android:height="10px" use android:layout_height="10px"
android:layout_width="180px"
android:layout_height="10px"
use android:minHeight="120dp" attribute.
if need to increase height dynamically add
android:layout_height="wrap_content"
You need to get rid of the "wrap_content" properties and just have the fixed width and height as so:
<EditText
android:id="#+id/Movile"
android:layout_alignBaseline="#+id/MovileLabel"
android:layout_alignParentRight="true"
android:layout_width="180px"
android:layout_height="10px"/>
<Button
android:id="#+id/inviteButton"
android:text="#string/invite"
android:layout_width="100px"
android:layout_height="5px"
android:layout_marginLeft="40dip"/>
You can't decrase size of TextEdit if the font is too big inside.
try android:textSize='6sp'

Categories

Resources