When adding a textedit to a dialog box in an xml file, for some reason, my textedit box displays bars (i.e unreadable text) when I enter text either from a real device or simulator (see screen shot.)
Text displays fine if I do this programmatically. Anybody had this problem? And was able to resolve it?
In conclusion, I changed the Layout Weight. Here is the xml for the EditText:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="2"
android:id="#+id/edittext_box"
android:layout_weight="1"
android:textSize="14sp"
android:paddingLeft="5dp"
android:textColor="?android:attr/colorControlHighlight"
android:inputType="number"
android:maxLength="4"
android:minWidth="40dp" />
Related
how do I prepopulate text (as user entered) into an input box in xml?
For example, I have a server box, how would I hard code text in there?
in the layout xml, it is set as
android:hint="server url"
I tried using android:text="#string/hostname" sfter adding to strings.xml in res values strings.xml:
<string name="host">http://example.com</string>
but that doesnt work. I need it to be hard coded in as if someone typed it.
Hint is just an overlay, but I need it entered in. What can I do? Id prefer only to use xmls
Here is my xml
<EditText
android:textSize="15.0dip"
android:textColor="#color/black"
android:textColorHint="#color/white"
android:id="#id/et_sever_url"
android:background="#drawable/selector_login_fields"
android:paddingLeft="20.0dip"
android:paddingRight="20.0dip"
android:focusable="true"
android:nextFocusUp="#id/et_password"
android:nextFocusDown="#id/bt_submit"
android:layout_width="fill_parent"
android:layout_height="50.0dip"
android:layout_marginLeft="25.0dip"
android:layout_marginTop="20.0dip"
android:layout_marginRight="25.0dip"
android:text="#string/host"
android:maxLines="1" android:lines="1"
android:layout_below="#id/et_password"
android:layout_centerHorizontal="true"
android:inputType="text"
android:textCursorDrawable="#null"
android:fontFamily="sans-serif" />
I am trying a very simple application that is displaying two text field and a button (background color changed).
This is appearing fine on Emulator but when i am trying the same on actual device, one text field is not displaying and button color changed to standard color.
Any quick help ?
Regards,
Gul
XML
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/enter_phone_number"
android:id="#+id/EnterNumberMsg"
android:clickable="false"
android:visibility="visible"
android:textStyle="bold"
android:textSize="15sp"
android:textIsSelectable="false"
android:textColor="#c816365c"
android:textAlignment="center"
android:password="false"
android:background="#fa538dd5"
android:layout_centerHorizontal="true"
android:layout_below="#+id/LogoMsg"
android:layout_marginTop="100dp" />
Change your margin from 100 dp to some other low value..because as you said its not visible, size of your cell is smaller than your emulator.
I have used EditText in my application, the problem is the entered text is not aligned properly, check it out my screen shot for what exactly my issue is.
My EditText XML file is
<EditText
android:id="#+id/signupFullName"
android:layout_width="179dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/updatedprofieledit"
android:ems="10"
android:hint="#string/enterfullanme"
android:inputType="textPersonName"
android:paddingLeft="10dip"
android:singleLine="true" >
<requestFocus />
</EditText>
Kindly help me to clear this issue, have tried with some EditText Specification but no luck.
Thanks
It appears that your background image is smaller than your hard-coded width. Adding padding reserves some "unused room" at the end of your EditText. It would be better if you converted your background image to a 9-patch image so that it could resize automatically.
add this line into your edit text
android:padding="5dp"
use this
android:paddingRight="10dip"
I have an EditText defined in my half screen RelativeLayout. and it appears perfectly. However, if I start typing typing more than 1 line in my EditText, it makes my entire entire window expand. I want the EditText to roll up and only show the currently typing line? Like in Facebook Messager, I want the EditText to keep scrolling itself as the user types new lines? HEre is how I implemented the EditText
<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_toLeftOf="#+id/button1"
android:ems="10"
android:focusable="true"
android:inputType="textMultiLine" />
Just set
android:maxLines="1"
This makes the TextView be at most this many lines tall.
I have seen many similar questions to this one but I think this still covers new ground:
1) Hint text disappears when you set gravity
2) android:ellipsize="start" fixes that so you can have centered hints and centered text
3) why does the code below still show centered hint text?
<EditText
android:id="#+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="use this area to provide specific identification information including approximate size, vessel name and registration numbers if available"
android:background="#android:drawable/editbox_background"
android:layout_below="#id/details_title"
/>
is it because of fill_parent instead of wrap_content? i thought maybe it was because this hint is multiline, but i shortened it and it still appeared and was centered. those are the only differences between this and my other EditTexts that needed android:ellipsize="start" to display correctly. is it just a bug?
You need to use android:gravity="top" instead of center in order to have your hint and your text start at the top left of the box.
add this attribute to your EditText
android:ellipsize="start"
It just works
<EditText
android:id="#+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:ellipsize="start"
android:hint="use this area to provide........"
android:background="#android:drawable/editbox_background"
android:layout_below="#id/details_title"
/>