I would like to figure out if it is possible to make Dropdown (Arrow) Logo of a Spinner smaller.
See my two screenshots please:
The first Screenshot shows that Dropdown label is pretty big.
The second shows what I really want to accomplish. It is not about the Dropdown, I want to have the ability to have more text when a item is already selected.
This is what I use as code:
<android.support.v7.widget.AppCompatSpinner
android:id="#+id/heroSpinner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="10sp"
android:autoSizeMaxTextSize="15sp"
android:dropDownWidth="match_parent"
android:popupBackground="#8A8A8A"
android:spinnerMode="dropdown" />
Can edit my mainActivity and Adapter if needed.
Can someone help me please? :)
Related
I have implemented AutoCompleteTextView, but in few devices (Mi and Samsung), it doesn't show options when the TextView is at the bottom of the screen.
NOTE: The Fields are dynamic, So I don't have option to move the view a bit above from bottom
image 3: check the correct here (Motorola device)
I tried:
AutocompleteTextView suggestion list goes up
Android : autocompletetextview, suggestion list displays above the textview?
AppCompatAutoCompleteTextView
Adding different windowSoftInputMode in Android Manifest
and many other things on StackOverflow, but nothing worked
my code
<AutoCompleteTextView
android:id="#+id/txt_drop_down"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:minHeight="#dimen/_40dp"
android:layout_weight="1"
android:background="#drawable/et_bottom_border"
android:completionThreshold="1"
android:gravity="center_vertical|start"
android:padding="#dimen/_10dp"
tools:text="Hello"
android:dropDownHeight="wrap_content"
tools:textColor="#android:color/black"
android:textAlignment="viewStart"
android:textColor="#android:color/white"
android:textSize="#dimen/_16sp"
tools:textSize="35sp" />
set android:dropDownHeight in xml to fixed number (e.g. 150dp). Then you will have fixed dropdown with scrollbar there. Also android:layout_height set to fixed size as well.
I've tried a tutorial on youtube but it doesn't work,when I click the button nothing happens.
When I press the button I want to Change the layout activity and also to be set on the new layout one random text from lets say other 10 and on this current layout I wanna have the button which will randomly change the first text to another one.
Here is what codes I've used and didn't worked out.
#I can't add the codes because It doesn't let me post it here..it says something like isn't valid but you see everything in the picture,so I did all that code and when I press on my button It doesn't doing anything,what can be the problem?and If you have any idea or if you know any tutorial to help me achieve what I said I want to do upper I would appreciate really much
#as you can see there is a string option which should give me one text of all of them when I click my button,but it doesn't
sorry for image but it seems like those codes aren't good
<LinearLayout
android:layout_width="332dp"
android:layout_height="184dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginTop="48dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="#+id/buttonsports"
android:layout_width="match_parent"
android:layout_height="129dp"
android:background="#drawable/ft"
tools:layout_editor_absoluteX="115dp"
tools:layout_editor_absoluteY="291dp" />
<TextView
android:id="#+id/sports"
android:layout_width="216dp"
android:layout_height="117dp"
android:text="TextView"
tools:layout_editor_absoluteX="95dp"
tools:layout_editor_absoluteY="246dp" />
</LinearLayout>
this is how big my text box is,the "sports" is the id for TextView which is "abc"
In your xml you have a LinearLayout for which you have set the height to:
android:layout_height="184dp"
and inside there is a Button with height:
android:layout_height="129dp"
So for the TextView below there is left maximum 55dp but you set:
android:layout_height="117dp"
This means that at least half the TextView is not visible.
In your code you set a random text to the TextView when you click the Button.
You say that nothing happens.
Is there a case that the text is being set but you can't see it because the TextView is mostly hidden?
Change the heights of the views and you will find out.
I know this question is repeated but I don't get the Proper solutions.
I want to bring arrow closer to the Spinner (That means i want to decrease the width of spinner and decrease the space between text and down arrow) I have used default spinner. How can I do that? Please, guide me to get Solution.
Here is the XML code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/relativeLayout15">
<Spinner
android:id="#+id/languageDropdown"
style="#style/SpinnerTheme"
android:layout_width="66dp"
android:layout_height="wrap_content"
android:entries="#array/Languages" />
</RelativeLayout>
As i am understanding your question, many time we face requirement to customise spinner UI and it is too tough to achieve this. I generally use this solution for such situations:
Solution: Hide your actual Spinner and show a TextView which just looks like our desired Spinner, Please have a look at below image for better understanding:
In above image I have created a phone number field where I am getting country code from user using Spinner. I created a TextView having text as country code with drawable[right] of down arrow. Please check below XML code for better understanding:
In above image Spinner width is 0dp so your Spinner will not be visible. Just remember one thin you have to handle click event of TextView and call performClick() method for Spinner. Please refer below image for this code:
On the click event of your TextView, just follow below way:
textViewLabelCodeRegister.id -> {
spinnerCountriesRegister.performClick()
}
That's It.
Make PopupWindow instead of Spinner.
[You can perfectly see the problem here, the drop downlist opens from the top of the spinner and not from the bottom and I don't know what to do, couldn't find any solution on google either, please help me] sorry for external image link, for some reason it wont load the picture here..
here is my spinner code:
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rgGender"
android:entries="#array/months_array"
android:textAlignment="center"
android:id="#+id/spMonth"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"/>
This would happen if the item which inflates the spinner is close to the bottom of the screen.
Since the spinner would not have enough room (or just barely enough room) if inflated downward, it is inflated upward instead. Try putting the spinner higher (vertically) in the layout.
It depends on Screen size, If you test it on other device it will show at down/up.
I suggest you to test it on different devices.
you can use custome adapter if you want
<Spinner
...
android:overlapAnchor="false" />
Please check this answer and this answer
I have a spinner with this code:
<Spinner
android:id="#+id/cover"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:prompt="#string/cover_hint"
android:layout_marginTop="10dip"
android:gravity="center"
android:layout_gravity="center_horizontal" />
Yet for some reason when it's first loaded (I am loading items in from an ArrayList<String>), it appears too small. Like the first image below. But once I select an item, then it appears normally like in the second image.
How can I get it to always appear like the second image?
You could try forcing the height with
android:layout_height="48dp"
That worked for me after I tried other things like android:padding and android:textSize, neither of which seemed to have an effect.