This question already has an answer here:
MultiLine EditText in Android with the cursor starting on top [duplicate]
(1 answer)
Closed 6 years ago.
This might look simple and might actually be simple but I need the following screen
I completed it using the following xml
<EditText
android:id="#+id/subject_edt"
style="#android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:inputType="textImeMultiLine"
android:layout_marginRight="15dp"
android:background="#drawable/edt_bg"
android:maxLines="5" />
everything is fine but the problem is, it is appearing as below on focus
the cursor should appear on the top left corner, can any one suggest how ti achieve this ??
Thanks in advance :)
Try to set this android:gravity="top" OR for left you can give android:gravity="top|left" property in your EditText.
Refer this.
<EditText
android:id="#+id/subject_edt"
style="#android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:inputType="textImeMultiLine"
android:gravity="top"
android:layout_marginRight="15dp"
android:background="#drawable/edt_bg"
android:maxLines="5" />
Use android:gravity="top"
<EditText
style="#android:style/TextAppearance.Medium"
android:background="#drawable/edt_bg"
android:gravity="top"
android:id="#+id/subject_edt"
android:inputType="textImeMultiLine"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:maxLines="5" />
Related
This question already has answers here:
ConstraintLayout views in top left corner
(5 answers)
Closed 5 years ago.
This(1st image) is how the layout is appearing in content_main.xml
https://s8.postimg.org/8ie65tzdh/Untitled1.png
But this(2nd image) is how it appears in the virtual device.
https://s8.postimg.org/wywc0enad/Untitled.png
I'm a beginner so I might be missing many things here. All kind of help will be appreciated.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.shanu.namerank.MainActivity"
tools:showIn="#layout/activity_main">
<Button
android:id="#+id/submit"
style="#style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="216dp"
android:layout_marginBottom="246dp"
android:layout_marginLeft="132dp"
android:layout_marginRight="132dp"
android:text="#string/submit"
tools:layout_editor_absoluteX="136dp"
tools:layout_editor_absoluteY="217dp" />
<EditText
android:id="#+id/name"
android:layout_width="279dp"
android:layout_height="70dp"
android:layout_marginTop="128dp"
android:layout_marginBottom="310dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
android:ems="10"
android:inputType="textPersonName"
android:text="#string/enter_name"
tools:layout_editor_absoluteX="41dp"
tools:layout_editor_absoluteY="129dp" />
<Button
android:id="#+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/check"
android:layout_marginTop="283dp"
android:layout_marginBottom="176dp"
android:layout_marginLeft="124dp"
android:layout_marginRight="124dp"
tools:layout_editor_absoluteX="126dp"
tools:layout_editor_absoluteY="284dp" />
<TextView
android:id="#+id/result"
android:layout_width="194dp"
android:layout_height="67dp"
android:layout_marginTop="356dp"
android:layout_marginBottom="88dp"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:text="#string/result"
tools:layout_editor_absoluteX="83dp"
tools:layout_editor_absoluteY="357dp" />
</android.support.constraint.ConstraintLayout>
enter image description here
You need to add "android:layout_marginBottom= x dp".
Bottom/Top/Start(for left)/End(for right) for all 4 sides. And for every element.
Or if you like more design side, just pull arrows from elements to the sides and then move elements over layout.
You have constrains on your views that are only for showing in the xml layout editor but will be ignored when running on an actual device. Android studio should be giving you warnings regarding the usage of anything with the text "layout_editor_". You need to give the view real constraints.
I'm facing an issue regarding EditText.
EditText is not working in couple of android devices when inputType:Text / TextMultiline/ TextPersonName.
but when you use inputType:Number
It works in all devices
what is the issue?
<EditText
android:id="#+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Quantity 1Kg Meat etc"
android:focusableInTouchMode="true"
android:textIsSelectable="true"
android:clickable="true"
android:inputType="text"
android:textSize="14sp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:layout_below="#+id/line1"
android:layout_alignParentStart="true" />
Firstly it didn't show the keyboard
then i use this
android:windowSoftInputMode="stateVisible|adjustResize"
after this i can't edit the text fields
if inputType:number then it works
One thing i want to add more is i'm using this in custom ListView
I think problem with android:textIsSelectable="true" try to remove and check
<EditText
android:id="#+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Quantity 1Kg Meat etc"
android:focusableInTouchMode="true"
android:clickable="true"
android:inputType="text"
android:textSize="14sp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:layout_below="#+id/line1"
android:layout_alignParentStart="true" />
android:inputType="textNoSuggestions|text"
android:focusable="true"
Working solution
If mobile text prediction is on then use above inputType to edit textfields
This question already has answers here:
How to set the hint of autocomplete textview in android
(3 answers)
Closed 5 years ago.
<AutoCompleteTextView
android:id="#+id/edtname">
I have tried android:hint and android:CompletionHint, but unable to show hint text on the AutocompleteTextView.
Thanks in advance !
Set this on xml:
<AutoCompleteTextView
android:id="#+id/autoc"
android:layout_width="wrap_content"
android:layout_height="wrap_conten"
android:ems="10"
android:text=""
android:hint="HintYouWantToGive" />
<AutoCompleteTextView
android:id="#+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="**Your Hint**" />
Use attribute android:hint to show hint text. You should use different color for hint text and background.
<AutoCompleteTextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="This is a hint"
android:textColorHint="#000000"
android:background="#FFFFFF" >
</AutoCompleteTextView>
I have an EditText that has 4 lines (min=4; >4 scrolls). The EditText is embedded in a TextInputLayout. The hint displayed for this seems to be centered vertically. I'd like it at the start of the 1st line, naturally.
Important Edit: Testing without TextInputLayout allows for the hint to be positioned effectively. The problem lies with this. Any insight into how to resolve it is appreciated.
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true">
<EditText
android:id="#+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:fadeScrollbars="false"
android:gravity="left"
android:hint="What's going on?"
android:inputType="textMultiLine"
android:lines="4"
android:minLines="4"
android:scrollbarStyle="outsideInset"
android:scrollbarThumbVertical="#drawable/custom_scrollbar_style"
android:scrollbars="vertical"
android:textColorHint="#color/black_semi_transparent" />
<TextView
android:id="#+id/text_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="140"
android:textColor="#color/black_semi_transparent" />
</android.support.design.widget.TextInputLayout>
This bug has been fixed in the v23 support libraries:
https://code.google.com/p/android/issues/detail?id=179720
I'm trying for days to align the text in a spinner to right, but every time I fail to do it,
I tried to set Gravity to right, or ellipsize to end but nothing works and all I have is this :
can you please help with this issue ?
Thanks a lot.
Here's the XML :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<org.holoeverywhere.widget.Spinner
android:id="#+id/spnCities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:entries="#array/array_cities"
android:gravity="right"/>
<TextView
android:id="#+id/tvCities"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="#string/city"
android:textAppearance="?android:attr/textAppearanceSmall" />
You probably have to use a custom view to enable this to work. Use google its your best friend...this will probably help:
Align spinner values to right instead of left
android:textDirection="rtl"