I have an input box - edittext in android, which is not single line. I want that when three lines are complete then the edittext should stop expanding and scrollview should attach to the edittext at that time.
I can add scrollview directly?
try like this way
<EditText
android:id="#+id/users_first_name"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:hint="First"
android:focusable="true"
android:inputType="textPersonName"
android:enabled="true"
android:maxLines="3"
>
</EditText>
use android:maxLines="3" for your EditText tag in xml.
Related
I have an EditText that is wrapped in a TextInputLayout that is inside a LinearLayout and I want to show a fragment when the LinearLayout is touched. However the EditText is intercepting the touch.
I tried setting focusable="false" and clickable="false" on the EditText and the TextInputLayout but now the touch doesn't do anything except change the hint color slightly for a little bit.
I don't want to set enabled="false" because of the grayed out style color changes.
My xml:
<LinearLayout
android:id="#+id/type_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:id="#+id/type_input_layout"
android:clickable="false"
android:focusable="false">
<EditText
android:id="#+id/type_input"
android:hint="Type"
android:text="Public"
android:clickable="false"
android:focusable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|textMultiLine"
android:background="#color/transparent"
android:gravity="left"
android:textSize="22sp"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
My solution for now: just put a view on top of the edittext
try this ,may be its working
set in your linear layout
android:clickable="true"
set in your editText
android:clickable="false"
android:focusable="false"
remove from TextInputlayout this 2 lines
android:clickable="false"
android:focusable="false"
Try android:enabled="false". I'm not sure but it might work.
Try using android:descendantFocusability="blocksDescendants" on your LinearLayout to make children view not focusable.
You can also try using both focusable properties
android:focusable="false"
android:focusableInTouchMode="false"
EDIT:
Try android:duplicateParentState="true" for every child view of the LinearLayout. You can also look at this question. There is someone mentioning that inputType on EditText can intercept the click.
In xml for EditText you should declare:
android:clickable="false"
android:longClickable="false"
This will make it not able to take over the click.
I know that is possible to disable editing EditText.
Answers is here, and here.
But, when i disable EditText it also disabled vertical scroll in this text.
Is it possible to disable only editing, but allow scrolling?
editText.setFocusableInTouchMode(false);
editText.clearFocus();
Use this porperties in your EdittText:
android:enabled="true"
android:focusableInTouchMode="false"
android:scrollbars="vertical"
Your EditText will be enable, but not focusable for edit. Then, you will able to scroll (in vertical on this case) and will not able to edit.
I've found that just disabling the key listener, focusable and cursor seems to work:
editText.setKeyListener( null );
editText.setFocusable( false );
editText.setCursorVisible(false);
As long as you keep the edit text enabled you seem to be able to scroll the text still.
If you wrap your EditText in a ScrollView then you should be able to preserve the scroll behavior.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText ... />
</ScrollView>
editText.setKeyListener(null) should help you.
Try to use these two attributes to your editext it will make your editext only scrollable not editable
android:inputType="none"
android:textIsSelectable="true"
Below is the example
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
android:padding="20dp"
android:layout_margin="10dp"
android:textSize="#dimen/text_size"
android:inputType="none"
android:textIsSelectable="true"
android:textStyle="normal"
android:id="#+id/toeditext"
android:textColor="#android:color/white"
/>
I have a ListView with EditText in each row. So I cannot type anything in any EditText as well as not focus when tap on them.
Xml souce:
<EditText
android:id="#+id/textValue"
android:layout_width="match_parent"
android:layout_height="37dip"
android:editable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="left|center"
android:inputType="text">
</EditText>
Thanks in advance.
If you want to be able to focus on the EditTexts, remove the lines that set it as non-editable:
android:focusable="false"
android:focusableInTouchMode="false"
Use TableLayout instead of ListView because EditText has focusable problems in ListView.
you made the EditText unfocusable with those two lines:
android:focusable="false"
android:focusableInTouchMode="false"
just remove or set the value to "true" in order to use them
I wanna make the editText to look like this:
what else should I do after I set the editText's background how can I make the text start inside the edittext via code.
Are you trying to get the EditText to say "Username" by default, but not have that be the actual text?
For that you can use EditText.setHint() (inherited from TextView) or in the xml definition use android:hint, such as
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Username" />
To make text look like that, set the Gravity attribute to left. The gravity of EditText element.
As well as setting the background of the EditText view, set left and right padding, e.g.
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:paddingLeft="7dp"
android:paddingRight="7dp" />
I have an EditText with the property:
android:minLines="3"
However, when I start typing, it types in the middle of the EditText.
Is there any way to get this to start typing at the top left of the EditText area?
Add android:gravity="top|left" to the EditText in the layout XML file.
Just insert
android:gravity="top"
into your EditText.
android:gravity="start" would put it to the top left.
This will help you. Try this EditText....
<EditText
android:id="#+id/edt_comment_note"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#drawable/white_box"
android:gravity="top"
android:hint="Note"
android:imeOptions="actionDone"
android:maxLines="3"
android:padding="5dp"
android:textSize="15sp" />