OK so I have a GridView of selectable items. Now, I am fully aware of how to create custom selectors for items. The problem is that whenever an item in the GridView is pressed, the selector is completely blocked by the grid item.
Is there any way to make it so that the selector appears over my grid item view? An example of this can be seen in the ''Play Music'' app. When you select an album in the grid a semi-transparent orange overlay appears on the item to indicate that it is being pressed.
Any ideas on how I would approach this?
OK so the solution to this is stupidly simple. You just use the attribute android:drawSelectorOnTop="true" in the XML element corresponding to your AdapterView.
Related
I have a GridView in which I am showing list of books. I have tried by creating custom layout and putting cancel button onlongclick listener of a view. But i am not able to apply a shaking animation to the items. Can anyone guide me how can i apply an animation to the items and make it similarly like iphone?
Now I want to provide feature to delete the Multiple items from the GridView like the View which shows as below:
I did lots of research for this ,but failed to get such kind of view in Android.
Can any one guide me for this?
You'll have to make a custom gridview for that. Place a button (x) on top of the grid item and set its visibility to invisible.. onLongPress of the grid item, make that button visible.. onclick of the button, delete that grid item by getting its id.
Hope I have given you a direction.
I have a list view in my app with elements where an image covers pretty much all of the view. There was an article by google where they explain that selectors should be drawn on top of the item if the item's background is not visible or else you wont see the selection highlight. Can't find this article anymore.
The list view has been correctly configured with drawSelectorOnTop and a selector for various states. Each item on a list view is a RelativeLayout with a background selector for various states including activated. When selecting multiple items and marking them as checked, the items are correctly marked but since a big image covers almost all of the view, just a fraction of the background is shown in the highlighted color.
I fixed my problem by wrapping the relative layout into a frame layout and setting a foreground drawable to draw the highlights. It works, but I don't like adding the extra layout on my elements.
Ideally, the selector of the listview should be used to mark the items, but apparently not. I included all possible states on the list view selector but it never leaves the item highlighted.
My question is: is wrapping items in a framelayout the correct way of doing this or is there a better approach?
I currently have a very plain ListView with no background image and just text for each item in the list.
Some people have voiced the problem that it isn't intuitive to click on the list items.
So I am researching what kind of a background image to create so that it makes the list item look "very clickable"
One option is to have the background image contain those little icons on the right that look have something like a ">" and its a sign that it should be clicked on.
But I am wondering what if the text is long on the listitem and it will overlap over the ">" icon. How is that usually handled? Is there a way to make text only extend 90% of the entire listitem?
Thanks!
The easiest and cleanest solution would be to make your TextView width match_parent and use the android:drawableRight attribute in your XML to specify the drawable that you want to be displayed on the right side of your text.
If you want to do something like every item on list should be shown clickable, just do one thing, design a layout with text view and inflate that layout in your lsitview adapter class in getview method. and instead of return convertview, return your inflated view from there.
I hope, my issue would be clear for you from my question title. I have three linear layouts in each row of the list view. One linear layout contains an Imageview and the other two linear layout contains text views. These three linear layouts comprise my list view row. But, to my surprise, the listview default selection(orange colored) does not work when I move the trackball of mouse or when I select it from the phone.
Can anyone guide me resolve this issue.
Any help is appreciated.
Looking forward..
By default, the list selector is drawn behind the currently selected item. If your item layout has an opaque background, the selector cannot be seen.
Try making your list item background transparent.
Did you add a background color to your row's layouts? If so, that color will be the only color you see - even on touch events.
A row's background should really be set to a selectable drawable with different colors for different states like selected and unselected.
I am using a couple of ListView elements in my app. In all cases, it doesn't highlight the selected item when I click/touch it, but I can use the trackball to scroll up and down, and can see the orange highlighted color then. How do I fix this?
For e.g., one of them is a LinearLayout with two TextViews in it.
Setting the background to the list_selector_background for the parent Layout element for each of the items did the trick.
android:background="#android:drawable/list_selector_background"