I've got listview that in a row it contain 3elements: imageview, textvie and another imageview. I've set my listview to setItemsCanFocus(true) and every item is set setFocusable(false). Screen:
http://img252.imageshack.us/img252/4042/zrzutekranue.png
I can navigate on the screen (click on text/image, I have those fields set to clickable and focusable), but there is no visible focus. I'd like to have the default focus style, when background changes.
I can add sth like:
setBackgroundColor(xxx)
but I'd like to have that fancy background that is lighter in the middle and darker at the ends.
The upper row on the pic is what I've got, and lower is the ideal focus notification, of course it should be narrow so it would only be background of the text view.
Sorry for my English.
PS I also used for textview
android:layout_height="fill_parent"
to fill for height which isn't the best piece of coding.
In the List View, all the list items are in different views. In your case the Image View, Text View And Image View lies within a single View. So according to me you cannot have focus on the items within a single View in a list View.
Related
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?
Context:
I've managed to create a custom BaseAdapter for my ListView which renders my elements correctly. I've got a nice 4x4 grid of items beautifully drawn.
Now I'd like to change the state of one of the items on pressed (like a button OnPressed state). I've achieved this with a custom control derived from button, and some custom states. This allows me to programatically or on touch, change the state of the item in question. Perfect.
Problem:
Now I'd like the elements (in a given state) to exceed the bounds provided by the listView. The adapter's getView method returns a view, but this (AFAIK) fits within the columns provided, with the listview expanding to fit the view returned. What I want is to specify the height of each row, but allow the item to fill beyond these bounds. For example, on press I'd like to draw a big circle around the item touched - this circle would overlap other elements as it encompasses the item; the circle exceeds the bounds of the element it encircles.
Is there a simple padding or layout parameter to specify allowing the Drawable to exceed the bounds of the space allocated by the list view? Or do I need another view of a circle ontop of the ListView and position at the right place on touch? (the circle is currently a background drawable of the button, shown via a selector for the correct state).
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.
If i have a expandablelistview with custom layout (group.xml and child.xml), the are any way to set a 9.png background for all the row(group + child? if is expand, only row if collapse).
For example i have 4 groups
1row collapsed with background
2row collapsed with backgound
3row expand
group <---- I want to use 1 background for group.xml and child.xml, this is it, the group background expands to be background for child too
child
5row collapsed with backgruond
Or, when i use expandablelistview, and define a row.xml background, when i expand a groupo, the background envolpes too to the child?
I am afraid this is not possible. Since you are referring to two different resource files in a ExpandableList, you can't group them as a single view. Being this the case, you can set the 9 patch to your total expandable listview which you might not want as your need. So here goes the round about method.
1)You can have three set of images. Once full closed image. second image can look like the top half of the first image and third image to look like the bottom half of the first image.
2)Add the listener on GroupExapnded() to your ExpandableListView. Now this will return you the position of the view, boolean flag of the view state(whether it is expanded or collapsed) and and the object to that view.
3)Now based on the boolean flag you have to play around with the images as of which image is to be as the background.
There will be two scenarios,
1)For the expanded state, you have to apply the second image to the group and the third image to the child.
2)If the group is collapsed , you have to apply the first image as the background to the Group View.
This is the most ugliest way which I know by myself. if you can get any better solution kindly inform me to.
I want to have ListView with some customized (layout) items. Background for those item has transparency on its bottom side. I want next item (after this customized) to be positioned a little bit top (something like minus margin in CSS). If in LinearLayout of list item (this special list item) I can do android:layout_marginTop with minus values? It seems to doesn't work, so what is the better solution? I need to little positioning next list item.
I don't think that the listView exposes this functionality. As an image trick, however, if you can modify the images, just put the transparent section (I assume it's a shadow?) on the top of your listItem background image so that it LOOKS like the item above casts a shadow, but in reality the shadow is part of the background of your listItem