I'd like to change the layout and color of the suggestion box I get in my Google Maps-API based app in Android Studio. I have no idea whether I should look into the code of Google Maps or somewhere else.
the link contains an image with the suggestbox I'm talking about
This is the code of the TextView:
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="50dp"
android:layout_toRightOf="#+id/ic_magnify"
android:textSize="15sp"
android:textColor="#ecf0f1"
android:id="#+id/input_search"
android:background="#null"
android:imeOptions="actionSearch"
android:inputType="text"
/>
And I use the PlaceAutocompleteAdapter to autosuggest the possible locations.
Fixed the problem by styling the dropdown popup.
I added android:popupBackground="#2d3e50" to the AutoCompleteTextView-style which changed the color to the one
I needed.
Related
Below is my code for EditText,
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/password_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/username_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:hintEnabled="false"
app:passwordToggleEnabled="false"
app:passwordToggleTint="#color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/login_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login_username_input"
android:layout_weight="0.0"
android:drawableEnd="#drawable/password"
android:background="#drawable/round_bg"
android:hint="#string/login_password_hint"
android:imeActionLabel="#string/action_done"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"
android:nextFocusDown="#+id/submit_btn"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:text=""
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textCursorDrawable="#null"
tools:ignore="RtlSymmetry" />
</com.google.android.material.textfield.TextInputLayout>
I am setting password eye icon programatically like below,
passwordLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
passwordLayout.setEndIconDrawable(GetDrawable.getDrawable("Show/Hide Password"));
passwordLayout.setEndIconTintList(ColorStateList.valueOf(getResources().getColor(R.color.color_white)));
This works fine in most of the devices. But getting below issue in Mi a2 Android Version 10.
I have two TextInputLayout for user name and password field
There is no issue while typing username field.
Next moved to password field. Now, the cursor stucked in first position and typing text is showed up in keyboard but not displayed in Edittext field. Only text is displayed after tapping somewhere else in screen
I am not sure why this happens in some devices
Found below question related to my issue. But no solution provided there.
TextInputEditText is not showing the typed text/number when typing
UPDATE
In this given a solution for my issue, Android Pie edittext does not adjustPan/resize while typing but using Hardware acceleration may lead to high memory usage. So afraid to use this solution.
is there any other way to solve this?
I tested the code on emulator on two android devices find nothing wrong with it used com.google.android.material:material:1.3.0
please update your color style it has no Legiblity
pan Adjuesment related issued loged in debug check that
try alpha or Rc MDC for libaray version bug
Finally you do is open issue at MDC github here
I am trying to set drawable in my button but its not showing properly. Here is what I want to achieve
but I am unable to get the required results.
This is what I am doing
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btnShareStore"
style="#style/yellowButton"
android:layout_marginTop="#dimen/margin_large"
android:layout_marginBottom="#dimen/margin_small"
android:layout_weight="1"
android:drawableStart="#drawable/ic_vector_share"
android:text="#string/lbl_share_store"
android:layout_marginStart="#dimen/margin_large"
android:layout_marginEnd="#dimen/margin_small"/>
and this is how it looks like
How can I move drawable to the adjacent left side of text?
Any help will be highly appreciated
You can try with this, keep in mind that it will need your app theme to be a descendant of MaterialTheme.
<com.google.android.material.button.MaterialButton
app:icon="#drawable/icon_search"
android:text="Hello"
app:iconGravity="textStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
I have this stupid and seemingly trivial problem with the properties of an EditText.
The properties I am trying to achieve for the EditText, are the following:
The contents of the view should NOT contain newlines. It can be text, numbers, symbols, but no newlines.
The soft keyboard should NOT display the enter button because of the above. It should instead display something like "Send" or "Done".
The contents of the view should NOT continue horizontally when reaching the edge of the screen. Instead I want to wrap the text, displaying it on multiple lines.
I have tried many different combinations, but I can not achieve this combination.
What I currently have is this, which is inside a RelativeLayout:
<EditText
android:id="#+id/comment_box"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="#id/preparation_text"
android:hint="#string/comment_hint"
android:inputType="textCapSentences|textAutoCorrect|text"
android:scrollHorizontally="false"
android:maxLength="400"
android:imeOptions="actionSend"/>
It achieves 2 of 3. No newlines possible, keyboard displays "Send" rather than the enter-key for me, but the text continues on one line.
Changing inputType="text" to "textMultiLine" wraps text correctly on multiple lines, but also overrides the keyboard to always display the enter button.
I have tried different solutions around the Internet, including setting the properties maxLines="4", singleLine="true" and possible others that I have forgotten again.
I can not find a combination that works.
Output:
Exp:
The op is on right track. I did some research found that some options gets ignored which are specified in XML. but if the same options are set in code then it should do the trick. I used the same XML fragment specified in the question.
<EditText
android:id="#+id/edit_text"
android:layout_width="match_parent"
android:layout_height="80dp"
android:hint="hint"
android:inputType="textCapSentences|textAutoCorrect|text"
android:scrollHorizontally="false"
android:maxLength="400"
android:imeOptions="actionSend"
/>
And by adding the following lines in the code, it helped in achieving what you want.
edit_text.setMaxLines(Integer.MAX_VALUE);
edit_text.setHorizontallyScrolling(false);
textShortMessage is the inputType that you are looking for:
<EditText
android:id="#+id/commentEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="100dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:gravity="left"
android:text=""
android:hint="hint"
android:textSize="16dp"
android:textColor="#android:color/black"
android:lineSpacingExtra="0dp"
android:lineSpacingMultiplier="1"
android:background="#android:color/white"
android:selectAllOnFocus="true"
android:inputType="textShortMessage|textMultiLine|textCapSentences"
android:singleLine="false" />
Refere to this to prevent paste function. To prevent pasting a new line.
Please use android:imeOptions="actionSend"
to solve your problem.
I have the same issue a long time ago, you have to programmatically change Edittext property on OnCreate().
So in XML, create your Edittext like this
<EditText
android:id="#+id/comment_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="80dp"
android:hint="Comment here"
android:maxLength="400"
android:inputType="textMultiLine" />
And on onCreate() (I wrote in kotlin not Java)
comment_box.imeOptions = EditorInfo.IME_ACTION_SEND
comment_box.setRawInputType(InputType.TYPE_CLASS_TEXT)
I'm new to Android development and found that I can setup a android:prompt attribute to a Spinner widget. Like so in my layout/my_layout_fragment.xml:
<Spinner
android:id="#+id/boxFunction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_row="14"
android:entries="#array/function_options"
android:gravity="fill_horizontal"
android:prompt="#string/function_prompt" />
I found several screenshots from the Android 2.x epoch which clearly shows the prompt, but I haven't had any luck finding any 4.x screenshots which shows me the prompt. And my compiled app on Android doesn't show it either.
Was the prompt deprecated in 4.x (and if so, where can I get the deprecated information)? Or did I miss something?
I don't think it is deprecated. Maybe from 4.0 it depends on another attribute called
android:spinnerMode
Here is a example which shows you how the prompt works with Spinner Mode attribute.
And before that let me make it clear that,spinnerMode can be set to either dialog or dropdown.
<Spinner android:layout_width="wrap_content"
android:id="#+id/spinner"
android:layout_height="wrap_content"
android:prompt="#string/app_name"
android:spinnerMode="dialog"/>
<Spinner android:layout_width="wrap_content"
android:id="#+id/spinner1"
android:layout_height="wrap_content"
android:prompt="#string/app_name"
android:spinnerMode="dropdown"
android:layout_below="#+id/spinner"
/>
As you can see the first spinner has the spinnerMode set to dialog and the next spinner set to dropdown.
here are the outputs,
Dialog Mode
drop Down
The prompt title I have used here is "Locale Test". Thought I have set it to both the spinners it is visible only in Dialog Mode spinner. So I think it speaks for it.
I tried to show a hint in the EditText of my form, but i can't see that hint that i have set in the XML Layout while my application gets deployed, but i can able see the hint in eclipse designer view, but while getting deployed the same hint suppose to appear is missing, i tried with all the possible ways still i could not get the hint in the EditText... This is one of the Edit Text layout that i have used..
<EditText android:id="#+id/SetTimerSec_EditText01"
android:layout_width="60sp"
android:layout_height="40sp"
android:singleLine="true"
android:layout_x="220sp"
android:layout_y="170sp"
android:hint="0"
android:inputType="phone"
android:textColorHint="#color/black"
android:gravity="center"
android:focusableInTouchMode="true" />
[link text][1]
Can anybody Help me..Please
Thanks in advance
[1]: http://imgur.com/PzomF.jpg
[ScreenShot of Designer View with hint displayed][1]
It seems like a SDK bug, or at least related to one.
http://code.google.com/p/android/issues/detail?id=7252
The hint shows up if you remove the following:
android:gravity="center"
add android:ellipsize="start" and your hint will show up and be centered!