im using a edittext box drawable where the border is little graphical like it has two line border.the thing is if i enter the text its overlapping with the edge of the box.how can i create a space/ gap in the beginning,so that i can enter the text after 1/2 spaces gap from the left end.
Thanks
EditText editText = (EditText) findViewById(R.id.textId);
editText.setText("EditText component");
editText.setSelection(3);
try this code to set cursor to position 3.
If you just want to add space at strting try adding paddingLeft attribute in your code.
Thanks.
Related
The default text position of TextBox text is to the right of the text box.
[x] TEXT
How can re-position the text above the box?
TEXT
[x]
Thanks
looking at this question seems like you just need to change drawableRight to drawableBottom.
You need to add the following line to your checkbox:
android:button="#null"
android:drawableBottom="?android:attr/listChoiceIndicatorMultiple"
I have editText which by default leaves lots of space. I added backgroud for textView, cause editText backgroud is not possible.
When I execute command: editText.setHeight(50); of no matter what integer it gives me same result:
My text gets cropped. I think somehow I need to reduce editText margins to fit my text here.
Main problem is that there is to much space between rows in first picture.
You can do like this
int reducedValue =5;
editText .setPadding(editText .getPaddingLeft()-reducedValue,
editText .getPaddingTop()-reducedValue,
editText .getPaddingRight()-reducedValue,
editText .getPaddingBottom()-reducedValue);
editText.setCompoundDrawablesWithIntrinsicBounds(editText .getPaddingLeft()-reducedValue,
editText .getPaddingTop()-reducedValue,
editText .getPaddingRight()-reducedValue,
editText .getPaddingBottom()-reducedValue);
As I enter text in editText it should automatically underline the text I entered. I need like as I continue to enter text in editText it draw like in background.
Can someone help me.
Use view with 1 dp of height and custom width with green background , inside framelayout over your editText, and handle custom_width same as you are handling image_width.
For underline effect in EditText you need to add this
//initialize edittext before
editText.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
I am having a strange issue, the words are cutting inside EDITTEXT i have set an image as background. Plz help me... for example here ffsds, is being cut, I want it to shift to bit right so that it doesnt get cut.
Increase paddingLeft value of edit text.
...
android:paddingLeft="100dp"
...
in xml layout.
Increasing the left padding is the easy solution. But if this smiley image is always on the left of the edittext, you can set the image by using the attribute android:drawableLeft on the edittext.
If I set text to my EditText and the text is bigger, the default behaviour is that the text is scrolled to right. Can I scroll it to left?
Example with EditText 8 characters long and text "Sample text":
Normal behaviour: [ple text]
What I want: [Sample t]
Set the cursor/caret location to first character of the EditText. You need to use setSelection.
Selection.setSelection(editText.getText(), 0);