Reputation: 5896
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/settings_unpressed" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/settings_unpressed" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
<!-- Focused states -->
<item android:drawable="@drawable/settings_unpressed" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/settings_unpressed" android:state_pressed="false" android:state_selected="true"/>
<item android:drawable="@drawable/list_selector_pressed" android:state_pressed="true"/>
<item android:drawable="@android:color/transparent"/>
</selector>
I have a listView which has a rounded corner, when I try scroll my listView the borders become sharped (like rectangle). Could anyone tell me how called state when we scroll listView. I use code in above but no result, maybe I should have another state?
Upvotes: 0
Views: 99
Reputation: 5896
I found the solution.
set android:cacheColorHint="#00000000"
and android:scrollingCache="false"
that't it.
Upvotes: 1
Reputation: 13582
You could set the background of the listView as a rounded-cornered drawable and then for every row item leave some margin. This the entire content of the listview lies within a rounded-cornered view
Upvotes: 0
Reputation: 5183
It's not possible in that way. You need to have different drawable resources for the top item, middle item, bottom item and in case the list has just 1 item. Then in your custom adapter, you need to change your getView in something like this:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//...
if (position == 0 && entry_list.size() == 1) {
view.setBackgroundResource(R.drawable.selector_rounded_corner);
} else if (position == 0) {
view.setBackgroundResource(R.drawable.selector_rounded_corner_top);
} else if (position == entry_list.size() - 1) {
view.setBackgroundResource(R.drawable.selector_rounded_corner_bottom);
} else {
view.setBackgroundResource(R.drawable.selector_middle);
}
//...
}
Check this tutorial, it is easy and very well done.
Upvotes: 0