I want to know why my autocomplete textview suggestion is hiding the autocomplete textview , i am attaching the picture for better understanding.
<AutoCompleteTextView
android:id="#+id/current_location"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/round_background_white"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:paddingLeft="5dp"
android:completionThreshold="1"
android:dropDownHeight="80dp"
android:dropDownWidth="wrap_content"
android:singleLine="true"
android:focusable="true"
android:textColor="#000000"
android:textColorHint="#000000"
android:dropDownListViewStyle="#style/DropDownListViewStyle"/>
Style.xml:
<style name="DropDownListViewStyle">
<item name="android:dividerHeight">2dp</item>
</style>
It's probably due to the custom drawable round_background_white.
Make sure you are specifying enough height & padding in it.
Also post your round_background_white over here.
Related
I'm experiencing a problem with the AutoCompleteTextView dropdown component.
As you can see from the image below, there are those black borders inside the popup that I cannot get rid of.
Black borders:
I'm an Android noob, and I already tried basically everything with any success.
Below the code, I'm using.
activity.xml:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:hint="Categoria"
android:layout_marginRight="#dimen/spacing_xlarge"
app:hintEnabled="true"
app:boxBackgroundColor="#color/white"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
<AutoCompleteTextView
android:dropDownSelector="#color/white"
android:id="#+id/private_place_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dropDownHeight="300dp"
android:inputType="none"
android:drawableTint="#color/white"
android:backgroundTint="#color/white"
android:editable="false"
android:textColor="#color/piumaBaseColor"
/>
</com.google.android.material.textfield.TextInputLayout>
dropdown_menu_popup_item.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:paddingLeft="#dimen/spacing_medium"
android:paddingRight="#dimen/spacing_medium"
android:paddingBottom="#dimen/spacing_medium"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="#style/TextAppearance.MaterialComponents.Body1"
android:gravity="center_vertical"
android:background="#color/white"
android:backgroundTint="#color/white"
android:textColor="#color/grey_extradark"
android:text="test"/>
Can you please help me? Thank you a lot!
This dark lined are additional background from PopupBackgroundView. For fix the issue just use for background the same surfaceColor as you have in your theme
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
...
<item name="colorSurface">#FFFFFF</item>
</style>
See:
Code:
<RelativeLayout
android:id="#+id/circle_card_payment"
android:layout_width="40dp"
android:layout_height="40dp">
<com.google.android.material.button.MaterialButton
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#color/colorBlack"
android:insetLeft="0dp"
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:text="W"
android:textColor="#FFFFFF"
android:textSize="16sp"
app:shapeAppearanceOverlay="#style/ShapeAppearanceOverlay_ButtonCircle50"
app:strokeWidth="0dp" />
</RelativeLayout>
style.xml
<style name="ShapeAppearanceOverlay_ButtonCircle50">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">20dp</item>
</style>
For confirmation that material button is containing full space, I sat material button color to black. and inside text color is white.
Can anybody give me the exact solution according to my situation? Please note that you should not increase the relative layout size from 40 to 50 dp, I know that can solve the problem, but logo size will be bigger and that is not appropriate.
Please note, I must need to wrap this button in any root layout. That is mandatory. Like right now my material button is inside Relative layout.
Why does MaterialButton text not containing full space?
The problem is with the material button because by default material buttons have padding. you remove or override that padding by setting padding attribute in the xml itself, this should solve the problem.
just add android:padding = "0dp" to solve this. or as Ricardo.A suggest in comment set in the style <item name="android:padding">0dp</item>
<RelativeLayout
android:id="#+id/circle_card_payment"
android:layout_width="40dp"
android:layout_height="40dp">
<com.google.android.material.button.MaterialButton
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#323232"
android:insetLeft="0dp"
android:insetTop="0dp"
android:insetRight="0dp"
android:padding="0dp"
android:insetBottom="0dp"
android:text="W"
android:textColor="#FFFFFF"
android:textSize="16sp"
app:shapeAppearanceOverlay="#style/ShapeAppearanceOverlay_ButtonCircle50"
app:strokeWidth="0dp" />
</RelativeLayout>
Result with default padding.
and Result with overriding padding to 0dp
Hope this helps, Happy Coding!!
All of my searches has led me to guides on how to change the text color of the spinner choices, but how do I change the color of the text and arrow on the spinner itself?
Here's a snip of my spinner. It's supposed to say "Mercury".
Here's my attempt at the style. It did change the arrow to white, but not the text. I only applied it to the spinner since it will mess up the rest of the activity.
<style name="Theme.LightText2" parent="AppTheme">
<item name="android:editTextColor">#ffffff</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">#ffffff</item>
<item name="android:textColorTertiary">#ffffff</item>
<item name="android:textColorPrimaryInverse">#ffffff</item>
<item name="android:textColorSecondaryInverse">#ffffff</item>
<item name="android:textColorTertiaryInverse">#ffffff</item>
</style>
UPDATE: I tried to apply it to the activity itself via the manifest and it worked, but it's messed up the rest of my activity.
If you want to achieve this do one thing , Take one textview and set arrow icon on right(Drawableright) customize your text text view as you wont and on click open dialog with single selection and on item selected set text to textview
Try like this and use spnrSelect.performClick(); on click of rlSpinner to open spinner
<RelativeLayout
android:id="#+id/rlSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/scale_20dp"
android:layout_marginRight="#dimen/scale_20dp"
android:layout_marginTop="#dimen/scale_1dp"
android:background="#null"
android:clickable="true">
<Spinner
android:id="#+id/spnrSelect"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clickable="true"
android:dropDownWidth="#dimen/scale_300dp"
android:scrollbars="none"
android:spinnerMode="dropdown" />
<TextView
android:id="#+id/txtSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingBottom="#dimen/scale_1dp"
android:paddingRight="#dimen/scale_1dp"
android:paddingTop="#dimen/scale_1dp"
android:text="#string/txtSelect"
android:textColor="#color/edt_hint"
android:textColorHint="#color/edt_hint"
android:textSize="#dimen/txt_12" />
<ImageView
android:id="#+id/spnrDownArrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/scale_10dp"
android:background="#drawable/arrow_icon"
android:rotation="90" />
</RelativeLayout>
Create array adapter which will inflate TextView from Layout_resource
then set your color to inflated TextView
your_spinnersp.setAdapter(new ArrayAdapter<>(context,R.layout.txt_spinner,lst_data));
in layout add TextView
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="8dp" android:textSize="16sp"
android:background="#ff0000"
android :textColor="#ffff00"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
My login screen locks like this
http://pbrd.co/UVekFg
with that code
<TextView
android:id="#+id/login_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="#string/login_label_text" />
<EditText
android:id="#+id/username"
android:layout_width="#dimen/textfield_width"
android:layout_height="#dimen/textfield_height"
android:background="#drawable/textfeld"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/login_password_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/password" />
<EditText
android:id="#+id/login_password"
android:layout_width="#dimen/textfield_width"
android:layout_height="#dimen/textfield_height"
android:background="#drawable/textfeld"
android:inputType="textPassword" />
Actually the first character starts directly on the left border of the edittextfield. Is there an option so that there a bit padding between the first character and the left border of my textbox?
Thanks
You should probably provide padding for all the four edges of the widget by declaring android:padding = 5dp attribute in your EditText.
From what I see in your screen shot, it would be better to use android:layout_margin attribute to provide breathing space between your widgets.
You'll want to set android:padding
But if you plan on using this custom EditText throughout your app, you may want to create a style and store all the custom pieces in there.
So for example in your styles.xml, you'd have:
<style name="Custom.EditText.Style" parent="#android:style/Widget.EditText">
<item name="android:background">#drawable/textfeld</item>
<item name="android:paddingLeft">6dp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
</style>
Then in your xml layout, all you'd need is:
<EditText
...
style="#style/Custom.EditText.Style"
/>
I want to have a single lined TextView to show up 3 dots at the end when the text is longer than the TextView. I don't know why - but I don't get it.
I already wrapped my head around similar StackOverflow questions, but I ended up with no solution. Maybe someone has some useful hints.
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<TextView
android:textStyle="bold"
android:text="Full Name"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_width="wrap_content"
android:id="#+id/lName"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:ellipsize="end"/>
</LinearLayout>
The LinearLayout above is nested into 2 other LinearLayouts. Maybe this is important to know. I already tried the attribute "singleLine" too, but some say this is deprecated and it doesnt work anyway.
Add the following styles in your styles file (typically styles.xml):
<style name="autoscroll">
<item name="android:singleLine">true</item>
<item name="android:ellipsize">marquee</item>
<item name="android:marqueeRepeatLimit">marquee_forever</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:scrollHorizontally">true</item>
</style>
Then add the style #style/autoscroll to your TextView:
<TextView android:id="#+id/lName"
style="#style/autoscroll" />
You can reuse your autoscroll feature easily when you want this way.
Add this in your xml for the TextView:
android:maxWidth="200dp"
android:maxLines="1"
As
android:singleLine="true"
is deprecated.
android:id="#+id/lName" android:layout_width="150dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="Avinljhakjhsajkhakjshda"
android:textSize="16sp"
This doesn't work with me unless adding 'android:ems' attribute along with the android:ellipsize attribute
android:ellipsize="end"
android:singleLine="true"
android:ems="8"
The ellipses did not appear while my text was selectable.
I needed to disable selectable text (which is the default):
android:layout_width="0dp" (match constraint)
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textIsSelectable="false"
It works with singleLine="true" but this attribute is now deprecated, use ellipsize and scrollHorizontally="true" instead.
Use this code it will definitely work.
<TextView
android:id="#+id/sAddress"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Adress"
android:textSize="14sp"/>