I am working with the simple ListView. Need to make this ListView round (not the every list item round, but the ListView itself). So for this purpose I use shape xml-file. It looks like that:
The problem appears when I need to change color of the items. This color overlaps border of the listview. And it looks something like that:
As you can see, the listView is square again, not rounded. How can I prevent this? Couldn't found the solution though it seems a pretty much common thing to me.
If you want to add space around you list item add in you list item layout..
android:paddingTop="2dp"
android:paddingRight="2dp"
android:paddingLeft="2dp";
android:paddingBottom="2dp";
or
android:padding="2dp"
Use padding in listview..
android:padding="5dp"
Related
I'm trying to create such a list of items in android, I am able to complete almost everything except the orange ribbon on the right top corner, I tried different methods to achieve this UI element but none of them works properly for me. I tried rotating a text view by 45ยบ with the ribbon image as background but the edges of the ribbon weren't perfect I also tried adding the ribbon as an image view and placed a text view on top of that but It was really difficult to place the ribbon and text view like this. So what is the easiest and most efficient way to achieve this?
Thanks in advance.
I don't think there is a native android component that supports such a feature. You can create a custom view making use of the path. Here is a great tutorial if you want to follow it.
Put this TextView into your FrameLayout/CardView:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff8f00"
android:textSize="16sp"
android:text="25% Off"
android:layout_gravity="end"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="-20dp"
android:rotation="45"
/>
To achieve best look, play with padding and margin attributes.
[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
Hello friends i wnat to make custom slidng drawer like you-tube in my application
When user click on any item it should be show me like above image which i highlight so any idea how can i achieve this ?
Yesterday I faced same problem
but this examples highlight selector in whole listbackground but i also want red color indicator at starting which is mention
You need to create two selector. 1. For whole item 2. for that red part
For that Place a view in listitem on left side and create a selector for it.
then use following code. Here android:duplicateParentState="true" works for you.
When this attribute is set to true, the view gets its drawable state
(focused, pressed, etc.) from its direct parent rather than from
itself.
<TextView
android:layout_width="3dp"
android:layout_height="match_parent"
android:duplicateParentState="true"
android:background="#drawable/selector_for_red" />
this is how I like that the application be
but when I slip a finger through the list it looks like
how do I change from black to transparent? Thanks
Maybe in the XML file in the part where your transparency will be.
android:background="#66000000" android:cacheColorHint="#00000000"
First 2 numbers control transparency.
Duplicate:
Background ListView becomes black when scrolling
I have a listview within which each item contains black text on a white background. When testing on a Nexus One, when scrolling down to read through the text, a black highlight appears over the text and makes it unreadable.
I am trying to figure out what is this setting so I can turn it off. I do not want anything to get highlighted when scrolling down through the list. How can I accomplish this?
Thanks.
You probably want to set the cacheColorHint to the same color as your background.
So, when you're defining your layout, just add android:cacheColorHint='#fff' to your ListView:
<ListView android:id="#+id/list"
android:cacheColorHint="#fff"
android:background="#fff"
...etc />
This may be a trick:
android:cacheColorHint="#android:color/transparent"
Another solution would be to set the backgroundcolor of your list to transparent.
I had the same issue and setting the android:cacheColorHint to transparent seems to do the trick