<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"
Related
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
The problem is there is a edittext and I would like to set it default has a cursor on it (but not focus and hide the keyboard )
try
android:textCursorDrawable="#null"
android:cursorVisible="true"
<EditText
android:id="#+id/comment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:background="#drawable/comment"
android:hint="#string/cmt"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textColor="#AAACAD"
android:textColorHint="#AAACAD"
android:textCursorDrawable="#null"
android:cursorVisible="true"
android:textSize="15sp" />
but not works. Please help. Thanks a lot
#user782104
You can use this attribute android:windowSoftInputMode="stateHidden" in your AndroidManifest.xmlfile where you declare that Activity.
so this way cursor will be in edittext but keyboard will not display.
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
I have an EditText like below:
<EditText
android:id="#+id/et_sum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#android:drawable/editbox_background"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:hint="Enter sum" />
But the hint is not displayed. Is it possible to display the EditText hint with inputType="numberDecimal" or not?
you can use
android:ellipsize="start"
to make the hint displayed with an inputtype and gravity
It appears to be a problem with using android:gravity="center_horizontal". Try removing that line as it made the hint appear for me.
Here is one of my EditText tags to compare with:
<EditText
android:id="#+id/txtNumbText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:inputType="numberDecimal"
android:singleLine="true"
android:hint="Number Hint Text">
</EditText>
Hi we can not use Gravity attribute and inputtype="number" attribute at a time so better to neglect gravity attribute.
if u want set hint in middle of edit text use like this : android:hint=" hint "
give space in hint text
<EditText android:id="#+id/xEt" android:layout_width="170dip"
android:layout_height="wrap_content"
android:layout_marginRight="20dip"
android:inputType="number"
android:hint=" numbers only "
android:layout_alignParentRight="true" />
My EditText configured as follows won't show the hint:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:hint="The hint..."
android:scrollHorizontally="true"
android:singleLine="true" />
It works if I set android:gravity="left" or if I remove android:scrollHorizontally and android:singleLine attributes, which is not desirable. Any suggestions?
using android:ellipsize="end" fixed it for me
Weird bug !! (but Android has a lot of these weirdo bug)
In Lollipop version the default text and hint text color is white for EditText.
So we have to change like this in EditText
android:textColorHint="#color/grey"
I wanted my single-line EditText box to scroll but keep the hint on the right also.
I had the same issue and got the hint to stick by keeping gravity="right", and setting singleLine="true" and ellipsize="end".
You need to give text color to hint
android:textColorHint="#000000"
No need of android:scrollHorizontally attribute. Remove it.EditText is a fixed item on the screen. we want scroll the layout contains the EditText is enough. that is the best design too. you have put android:ellipsize="end" instead of android:scrollHorizontally.
Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :(
I found no other solution than to:
if (android.os.Build.MANUFACTURER.matches(".*[Ss]ony.*"))
editText.setGravity(Gravity.LEFT);
else
editText.setGravity(Gravity.CENTER);
The below worked for me:
<EditText
android:id="#+id/UserText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/UserPassword"
android:layout_marginTop="85dp"
android:ems="10"
android:hint="#string/UserHint"
android:inputType="textPersonName"
android:singleLine="true"
android:text="#string/UserName" >
<requestFocus />
</EditText>
This is how, I did for by EditText to have hint in it.
<EditText
android:id="#+id/productQuantity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right|center_vertical"
android:hint="#string/quantity"
android:inputType="numberSigned"
android:ellipsize="end"
android:singleLine="true" >
</EditText>
Try changing the hint text color, sometimes the hint color is the same as the background color
android:textColorHint="#color/colorBlack"
I changed the style to "#style/Base.WidgetMaterialComponents.TextImputEditText". For me it wasn't gravity or color.