When I touch my EditText, the virtual keyboard opens and I can edit the text, but I have no cursor that tells me where the next char would be, and no blue rectangular shape that would tell me if I touched the EditText or what EditText was touched.
The code is:
<EditText
android:id="#+id/search_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FCFCFC"
android:hint="\?"
android:inputType="text"
android:text=""
android:textColor="#000000"
android:textSize="24sp" />
What did I do wrong or what do I need to add?
Setting the android:textCursorDrawable attribute to #null should result in the use of android:textColor as the cursor color.
it will work
Related
<EditText
android:id="#+id/searchTextView"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/marginSmall"
android:layout_toLeftOf="#+id/searchCloseIcon"
android:layout_toRightOf="#+id/searchIcon"
android:background="#drawable/rounded_rect_white"
android:backgroundTint="#android:color/transparent"
android:gravity="center_vertical"
android:hint=" Search Nearby Chat"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:textColor="#color/black"
android:textColorHint="#color/black38"
android:textSize="#dimen/sunheading" />
Initially I can see cursor in edittext but after setting its visibility gone
and
again making visible its not visible in edittext.
May I know what can be the solution for this?
to show cursor,
android:cursorVisible="true"
android:focusable="true"
android:focusableInTouchMode="true"
and In your EditText, use the property: to make it drawable
android:textCursorDrawable="#drawable/blue_cursor"
Setting the android:textCursorDrawable attribute to #null should result in the use of android:textColor as the cursor color
programatically :
searchTextView.setCursorVisible(true);
searchTextView.requestFocus();
When you set your container visibility VISIBLE also try to request focus to your EditText
findViewById(R.id.searchTextView).requestFocus();
android:textCursorDrawable="#drawable/color_cursor"
How to make the whole TextView underline at the width of match parent like EditText?
This line of code only underlines the text, not the whole TextView.
textView.setPaintFlags(textView.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);
The reason I want to use TextView is that setOnClickListener is triggered immediately in one tap for TextView, whereas two taps are required for a disabled editable EditText.
You can put the background of an EditText on your TextView. For example:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your text"
android:hint="My hint"
android:textColor="?attr/editTextColor"
android:background="?attr/editTextBackground"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>
You might want to change the text appearance to android:textAppearance="#style/TextAppearance.AppCompat.Button" if you are using an AppCompat theme.
You can achieve this without writing many lines of xml attributes:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your text"
android:hint="Your hint"
style="#android:style/Widget.EditText"
/>
I have a very big text field but writing on it is not as I'd like. Is there a way I can move cursor to the top left of the field (so that it looks like a text area). Because by default it is centered. Thanks a lot
I use:
<EditText
android:layout_width="400dp"
android:layout_height="500dp"
android:id="#+id/editText"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
Add android:gravity attribute to EditText with value top|left.
android:gravity="top|left"
I know how to set the cursor visible in an EditText. But I dont want the EditText in itself to be clickable and editable without using the buttons in my application.
Consider an scientific calculator where you have the blinking cursor, but I dont want the user to be able to click on the textbox. How can I accomplish this?
in my my main file I did set:
inputText.setCursorVisible(true);
where inputText is of class EditText.
<EditText
android:id="#+id/textIn"
android:clickable="false"
android:editable="false"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:textSize="20sp"
android:gravity="left"
android:background="#drawable/inputview1"
android:textColor="#color/black"
android:layout_marginLeft = "5sp"
android:layout_marginRight = "5sp"/>
I have an EditBox in which I set the input type as textMultiLine. The issue is that the cursor in the EditBox always appears at the center of the EditBox, But I want it to display at the top left of my EditBox.
So why this happens?
Code for EditBox
<EditText
android:id="#+id/notes_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#drawable/img_add_notes_textbox"
android:inputType="textMultiLine"
android:maxHeight="30dp"
android:paddingLeft="15dp"
android:scrollbars="vertical"
android:textColor="#121212" >
</EditText>
ScreenShots
Because, by default gravity of EditText is center so just set it to top
android:gravity="top"
You need to set android:gravity="top|left" to your EditText