android-edittext

Android EditText with fixed number of max lines and no scrolling

喜你入骨 提交于 2019-12-06 04:53:15
I would like to create a text input that: 1) Always displays 3 lines 2) Does not allow the user to enter any more text than the available space in the 3 lines 3) Is not scrollable, if users enters text greater than 3 lines. Technically, I allow for the user to enter up to 500 chars for saving to DB, but I am not expecting near this amount of text for the input. So, my usage of maxLength is only precautionary. Here is my current EditText: <EditText android:id="@+id/edit_description" android:layout_width="match_parent" android:layout_height="wrap_content" android:lines="3" android:maxLines="3"

set spaces between letters in textview

柔情痞子 提交于 2019-12-06 04:48:45
问题 is there a way to set a custom space (in pixels) between letters to an editText? I found only how to set spaces between the lines, but bot between letters on the same row 回答1: I had to do this myself today so here are some updates about this problem : From API 21 you can use XML attribute android:letterSpacing="2" or from code myEditText.setLetterSpacing(2); Before API 21, use a TextWatcher with the following code private static final String LETTER_SPACING = " "; private EditText myEditText;

Capture entire content of EditText into a picture

空扰寡人 提交于 2019-12-06 04:19:10
I have to print the entire text of a text field into a picture. The reason is: I have to exchange messages with unsupported UTF-8 characters between Android and other web clients. By unsupported UTF-8 characters I mean missing fonts in Android (see this topic here ). I tried to use the direct way Bitmap b; EditText editText = (EditText) findViewById(R.id.editText); editText.buildDrawingCache(); b = editText.getDrawingCache(); editText.destroyDrawingCache(); which works like a charm until I have multiple lines: The solution captures only the text which is visible to the user instead of the

How to restrict the EditText input content

三世轮回 提交于 2019-12-06 03:47:15
I am trying to create a simple calculator which provides the EditText for the users to input the numbers. The allowing input content should be [1,2,3,4,5,6,7,8,9,0,.] I know that it is possible to limit the input content by using following code android:digits="1234567890." android:inputType="phone" But how can I prevent the users from adding more than one dot ( . ) into the EditText Box? You can use this digits attribute android:digits="0123456789" You can use InputFilter limit characters in an EditText as: EditText mEdit = (EditText)findViewById(R.id.mEdit); InputFilter[] filters = {new

EditText freezes/doesn't show text whilst typing

孤人 提交于 2019-12-06 03:42:49
问题 In my Android application I have an EditText which is sat inside a LinearLayout . This page is used in a ViewPager . On majority of the devices I have tested on, it seems that the EditText behaves perfectly fine, except on a few. It appears that on a few devices, when I touch the EditText and start typing, the text doesn't show but the suggestions do show. It is only after the Keyboard is closed that the text appears within the EditText . Why is this the case? Why does the text not show

clickable drawable inside EditText in android

隐身守侯 提交于 2019-12-06 03:21:16
I have an EditText with a drawable inside. I want to make the drawable clickable so that I can have a specific action when user clicks the drawable. How do I do that? My EditText is: <EditText android:id="@+id/phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="5dp" android:drawableRight="@drawable/question_mark" android:hint="phone number" android:imeActionId="@+id/phone_num" android:maxLines="1" android:singleLine="true" android:textColor="#000000" /> As Gina suggested above, you can achieve

Hint in Android

帅比萌擦擦* 提交于 2019-12-06 03:15:42
I tried to show a hint in the EditText of my form, but i can't see that hint that i have set in the XML Layout while my application gets deployed, but i can able see the hint in eclipse designer view, but while getting deployed the same hint suppose to appear is missing, i tried with all the possible ways still i could not get the hint in the EditText... This is one of the Edit Text layout that i have used.. <EditText android:id="@+id/SetTimerSec_EditText01" android:layout_width="60sp" android:layout_height="40sp" android:singleLine="true" android:layout_x="220sp" android:layout_y="170sp"

Android: showing text in EditText from start

和自甴很熟 提交于 2019-12-06 02:59:55
I have an EditText view in my xml file with a certain width. I have forced it to 1 line, so that if the entered text is longer than the width of my edit text, the text does not wrap around by using: android:singleLine="true" However, after entering a long text (longer than the width of edit text) it shows the last part of the text. I would like after user finishes entering the text, the text to be shown from the start. For example assume I have an edit text with a width that only accepts 4 characters. So if I enter "ABCDEFG" in the EditText box I see "DEFG" but I want to see "ABCD". How can

How to auto fill an edit text in android application?

北城以北 提交于 2019-12-06 02:00:40
I am developing one android application. In which I have some Products and form to purchase that product. In the Order form I have one Edit Text as Product ( means product name) . In my application user has to type Product name but I want to know that Is there any way that the EditText field is autofilled with that particular Product like as in flipcart. Any one knows then suggest me... Thanks in advance... When you want to populate it just call (after reading it in from the XML layout in this example): EditText myTextBox = (EditText) findViewById(R.id.editBox); myTextBox.setText("My Product

How to implement a simple Syntax highlighting method for edittext?

。_饼干妹妹 提交于 2019-12-06 01:47:55
问题 I am making an app that involves coding and I need edittext to recognize if the word typed was 'something' then depending if it is registered to be colored, it will color the word. Here is what I want to do, when the user is typing and types 'function' I want it to automatically highlight. Same goes to any other 'function' word, '()', ' " ', and many other words the user types. 回答1: You can accomplish this by using a TextWatcher like so: editText.addTextChangedListener(new TextWatcher() {