I am using custom row view in ListView widget.
I am having getView method in my implementation.
What I want is that I want to hide divider image of 2nd row how can I do it?
If you're talking about the image that displays when you call setDivider, or android:divider in XML, I don't think you can hide it on some rows and show it on other rows.
Instead, you can create a PNG (probably with draw9patch) with a border on the top or the bottom, and in your ListAdapter.getView() set it as the background on whatever rows you want. On the other rows, you can set a background that has no border. This will give the appearance that some rows have a divider, and others don't.
Related
I have a standard list where the rows contain images and textviews.
I would like to have the ListView's default listSelector to show up at the highest Z-index. Currently, it shows the animation under/behind the images. I want it to show the listSelector animation on top of the images and TextView.
Is this possible without creating a dummy ImageView in the row itself?
As per freddieptf's comment, the solution is to set "drawSelectorOnTop" to true on the ListView.
http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:drawSelectorOnTop
How to create this below view.
1)using listview or
2)inflating custom view in scrollview.
This is not only problem.
If list view then how to overlap the rows.
Each row have different color and that will come from api webservice.
In listview, at each row i have problem with red part which i have marked in second image.
even each row background is different and that same color will appear in below row.
How to do texture effect in listview?
The issue breaks to many things:
How to draw overlapping views?
I would try setting negative values for vertical paddings, but it's a wild guess. Also, you can just divide the graphics and draw views as rectangles containing view N and some parts of the N+1th view.
What about non-rectangular hit area?
You can manually detect clicks using color picking, shapes, or just simplify the view's clickable area to a rectangle.
What about visibility detection?
ListView shows only views, which are visible. I'm not sure, but most likely it won't work with negative paddings or similar hacks.
Personally I would write a custom view with ListView-like adapter and dynamic row loading.
I have try a many ways, and the best and fastest is simple set negative divider to listview like so:
android:dividerHeight="-100dp"
I'm an Android newbie. I want to create a screen with some expandable headers as illustrated. I've created the 1st row "gff" as shown.
However, each row under gff shows a space in between rows. Also, the ListView does'nt fill the width of the screen and leaves a margin on the sides and above.
How can I get the header and caption to fill the entire length of the screen as shown in the diagram? Also, how can I get the rows to show a different color?
Is there an example or code that does something similar?
Try setting divider of ListView to null, like listView.setDivider(null), this should help. Also you can set listView.setSelector(null) this should remove unnecessary margins.
I have three items in a ListView. The reason I have chosen the ListView is so I can use a Divider and a List Selector on these items.
However I do not need/want the scrolling aspect of the ListView. Ie. When I select/drag an item from the list, I dont want it to scroll..
Is it possible to disable this somehow? Or will I have to add the items using a LinearLayout and find another way of using a list divider and selector?
I'm not sure how well this will work for you, but you can disable overscroll (available in android-9 and above):
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
and then also hide the scroll bars:
listView.setVerticalScrollBarEnabled(false);
After this, if your list does not exceed the screen size then it shouldn't be able to scroll.
If you dont need to scroll listview, you can add the list item to a linear layout as well you can design it also through xml file.
And for put a DIVIDER to it just take a "View" widget.
Put it height 1 dip and width fill_parent. You can give color to this view through background color.
Try it. i have done it many times.
I've got a ListActivity with a ListView in it. I need to draw a repeating image around the border ("on top of it (I guess after the listview is renderered))
How can I hook in my own drawing code for this?
You can use a FrameLayout to cause the ListView to overlap with a view that fills the entire screen. In this background view you could tile an image, or write your own custom View with your own drawing method.
There is no border property in ListView, as far as I know.
Instead you can put ListView into a FrameLayout and set the Background color of the FrameLayout.
Finally, set some padding to FrameLayout in order to create a border effect.
Hi
There is one way I have used, but that can be done in XML only.
android:background="#ffffff"
android:divider="#ffcccccc"
android:dividerHeight="1dip"/>
What I am doing is, putting listview in a LinearLayout. Background color of the list is different than that of layout. There is a margin set for layout. Hence the distance between list and layout will appear like a border for the listview.
Hope this helps.