When i build my application in android studio and test it on my phone, the edit text doesn't behave like a text editor and creates a popup input field above the keyboard and waits for you to press done. What I want to achieve is to behave like a text editor and get direct input from the keyboard without pressing done every time you want to add something.
I have tried everything in terms of xml attributes. I even searched how other text editor apps achieve the direct input, but with no avail, the popup field that gets the input and waits for you to press done didn't disappear. Here is my xml code for the edit text:
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/code_edit_text"
android:scrollbars="vertical"
android:inputType="textMultiLine"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:lines="16"
android:gravity="top|left"
android:maxLines="10000"
android:singleLine="false"/>
I think its better to try after removing
android:background="#drawable/code_edit_text"
android:scrollbars="vertical"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
these lines
Related
I have a layout with two text input fields, which disappear & re-appear as options change.
However, when I use attribute app:endIconMode="clear_text", these two warnings flood the logs without end, for both of the text fields.
W/View: requestLayout() improperly called by
com.google.android.material.textfield.TextInputEditText{ba3099c
VFED..CL. ......ID 0,0-1244,272 #7f0a00c6 app:id/homeInput} during
layout: running second layout pass
W/View: requestLayout() improperly called by
com.google.android.material.textfield.TextInputEditText{f641714
VFED..CL. ......ID 0,0-1244,224 #7f0a00e6 app:id/lockInput} during
layout: running second layout pass
The text fields that are visible depends on RadioButton selections
Snippet of one of the text field XMLs:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/alt_sub"
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="40dp"
android:animateLayoutChanges="true"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:boxStrokeColor="#color/colorAccent"
app:endIconMode="clear_text"
app:hintTextColor="#color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/main_sub">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/lockInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_+"
android:fontFamily="#font/opensansregular"
android:inputType="textNoSuggestions" />
</com.google.android.material.textfield.TextInputLayout>
Whenever I call setText() or setHint() in the Activity class, the warning starts to pop up. The warnings only stop when the text field is empty.
I feel that this may be related to the attribute app:endIconMode="clear_text", but I can't find a way to use it without getting these warnings.
I had the same issue with different endIconModes and didn't find any solution on the internet so I opened a defect with google:
https://issuetracker.google.com/issues/132651327
The issue was fixed today and it should work properly in com.google.android.material v1.1.0-alpha07 when it will be released this week.
I have a TextView in my android app that I want to display all the text on a single line. Right now, it is displayed like this:
this is som
e text
When I set setSingleLine(), I get this:
this is som e text
(notice the space within some)
When I use setMaxLines(1), I get this:
this is som
What I want is this:
this is some text
How can I force the text to display fully on a single line?
You can try this on your textview's xml:
android:maxLines="1"
You can make scroll text using following code if you want.
<TextView
android:id="#+id/txtBigLongTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAlignment="center"
android:textSize="18sp"
android:textStyle="bold"
tools:text="long text goes here......................"/>
The answers above provide a solution to my issue.
The problem was the previous programmer had implemented logic which automatically started a new line after 20 characters.'
Thanks for your help everyone!
I am having some problems to underline an EditText in AndroidStudio.
This is what I am looking for (this is just a photo, not my real text):
But I do not really know any property to do that.
My code right now is really simple. Just the "normal" one:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:layout_margin="16dp"
android:id="#+id/tx_titulo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#string/pt_titulo"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:allowUndo="true"
/>
I do not want to underline just the text (in this case "TÃtulo"), but the whole PlainText
Does anybody know it?
Greets.
It is default, but try to check your styles. Maybe there is a style that will override the style in the whole application. If there is, just remove it
To do this programatically, you could find an answer in this post.
To set the underline color:
editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
To remove the underline color:
editText.getBackground().clearColorFilter();
To do it from the XML, you could add background property to do the same thing in your layout.xml with any drawable resource as a background by adding:
android:background="#drawable/mydrawable"
If you have a couple of EditText with the same style configuration, to avoid setting the attribute to each EditText, you could override EditText's default attributes, defining a custom style like it is done here.
I have the following Textview:
<TextView
android:id="#+id/detailsText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Long text Long text Long text Long text Long text Long text "
android:textAppearance="?android:attr/textAppearanceLarge"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true" />
The text is automatically scrolling from right to left (which is what I'm looking for) but after a configuration change the text restart scrolling from the beginning. I have tried to use android:configChanges="orientation|keyboardHidden|screenSize" and handle the configuration change in my code but this is not working. I also find out that this technique is not advised anymore, and tried to use Fragments instead, but nothing is working. I tried also to find out which value scrollHorizontally is modifying to do it's scrolling so I can try to save and restore it, but I never find it (textview.getScrollX() always stay at 0 for example).
I also noticed that this "scrolling restart" also happen when I use the textview.setVisibility(View.GONE); and textview.setVisibility(View.VISIBLE); methods.
Thanks for the help.
can any one suggest how can i have a list of icons like browser icon,email icon and contacts icon upon clicking on those it should lead to android browser,email and contacts apps respectively...right now i have done it, upon clicking buttons. Now i want icons(with image and text) instead of buttons...
Check this out:
http://developer.android.com/resources/tutorials/views/hello-formstuff.html#CustomButton
This will show you had to put the images you want in res/drawable/ and then load them up as buttons in your app.
There is no widget icon.
You can do it yourself using a LinearLayout an ImageView and a TextView.
The xml should be something like this:
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/your_image"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/your_icon_text"/>
</LinearLayout>
You can use Android Image Button and set its property "Clickable=true" and do the required work on its click event listener
I thought you want to have ImageButton , clicking on that you want to open particular application/browser/contact list.
ImageButton - Displays a button with an image (instead of text) that can be pressed or clicked by the user
<ImageButton
android:id="#+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon/>
If you wants ImageButton with Background button then set android:background attribute, as below:
<ImageButton
android:id="#+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"
android:background="#drawable/background_image"/>
If you want an image and text in your button, the way I do it is create a 9 patch, so I can define where the text will go using the padding and stretchable areas. Then follow the same instructions as for the Custom Button already mentioned, but use a standard button, not an Image Button.