I have the Following View in my XML. I am setting the childDivider to a color. But my child divider is not visible.
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/contacts_first_level_list_view"
android:childDivider="#color/text_color_grey_directives"
android:dividerHeight="#dimen/d1"/>
Please let me know if i have to do any thing other than this to see the divider only between Childs(No Divider between parents). Thanks.
I just ran in to this problem and finally found the answer. Check to see that isChildSelectable() is set to return true. (I know this is old but it may help someone.)
Related
I am going on with the scroll action in my Android Device if i scroll any thing in the device after it reaches the end point in top and bottom if even we scroll it shows some colours for different device eg:(samsung it shows blue light).
Here i attached a screenshot below:
How can we remove it or if no chance can we change the color
Usually we will use ScrollView,Listview etc to scroll the view should go on with XML or progrmatically.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollingCache="false"
android:fadingEdge="none" >
TRIED
android:cacheColorHint="#00000000"
android:scrollingCache="false"
list.setCacheColorHint(Color.TRANSPARENT);
android:fadingEdge="none"
listView.setVerticalFadingEdgeEnabled(false);
android:overScrollMode="never"
But no change can any one help me to fix this issue.
this effect is named overscroll
listView.setOverscrollFooter(new ColorDrawable(Color.RED));
listView.setOverscrollHeader(new ColorDrawable(Color.RED));
be awared that some devices ignores this params, example here
I don't know how to completely disable the overflow in the ScrollView, but I have come across a library that you can use so as to change your overflow color.
LINK:https://github.com/AndroidAlliance/EdgeEffectOverride
Here is the solution which helped me to solve
Custom overscroll glow/edge color for ListView?
for the user Menny
referred link:http://evendanan.net/android/branding/2013/12/09/branding-edge-effect/
Hope this help's you
I'm going to explain (or at least try that) what I want to achieve because this is driving me crazy.
I have a ListView and the items have the following layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/item_background"
android:duplicateParentState="true" >
... some contents here...
</FrameLayout>
</FrameLayout>
"item_background.xml" contains a selector so the background changes depending on the item's state. It's working fine when I press and release the item but it's not working when I 'select' the item with a DPAD/Trackball. I have tried everything (state_activated, state_focused, state_selected...) but nothing works. I'm trying to search for a solution but looks like I can't find the proper keywords to search for.
Any ideas?
Thank you!
Finally I fixed it. The problem was in the order I put the items inside the selector (I put a state_pressed="false" before the state_selected="true").
Now it works flawlessly.
Thank you everyone for your help.
This does most likely not work because some layout above your root layout gets the focus (hard to tell without the rest of the layout).
I have a small problem with my scroll view. Whenever a scroll view has over scrolled, it shows a yellow gradient (in my device, it may vary for other devices) at edges of scroll view. It can be eliminated by setting attribute as below in android 2.3 and above.
android:overScrollMode="never"
Now i want to change the default color to some other. How to achieve this.
Please help me regarding this. Any help will be appreciated.
You should use the following attributes on your ListView :
<ListView
...
android:overScrollHeader="#drawable/header"
android:overScrollFooter="#drawable/footer"/>
You could also set them programatically using setOverscrollFooter(Drawable d) and setOverscrollHeader(Drawable d).
This EdgeEffectOverride library works nicely for all scroll-type views: https://github.com/AndroidAlliance/EdgeEffectOverride
E.g.
<uk.co.androidalliance.edgeeffectoverride.EdgeEffectScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
...
app:edgeeffect_color="#color/red"
/>
And
EdgeEffectScrollView gridView = (EdgeEffectScrollView) root.findViewById(R.id.myscroll);
gridView.setEdgeEffectColor(Color.RED);
I'm using ListActivity with my own ArrayAdapter class. When I override the methods ArrayAdapter.areAllItemsEnabled() and ArrayAdapter.isEnabled() the divider between some cells in the list view disappear. Does anyone know how to avoid this? I need the dividers to display even for disabled cells.
Return true in areAllItemsEnabled() and false in isEnabled for specific item. The disabled item wont be clickable but you will still be able to view the divider lines
Note: This doesn't work for Android 5
You can essentially disable a list item by giving any one of its elements the following properties.
android:focusable="true"
android:clickable="true"
So the following list item layout will not be clickable, but will show dividers, without the need to implement areAllItemsEnabled() or isEnabled(int position).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:clickable="true">
<TextView
android:text="Large Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
This may help in Android 5.0 where the original answer no longer seems to work.
This worked for me. This will show the divider as well as disable the click on list item. Even in Android 5.0.
Set this on the list item
android:focusable="true"
android:clickable="false"
Setting just clickable to 'false' didn't work for me.
And Overriding isEnabled() caused the above mentioned issue of hiding the divider in 5.0.
And my ListView looks like this.
<ListView
android:id="#+id/lvItems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#color/Gray"
android:dividerHeight="1px">
</ListView>
No android:listSelector="#android:color/transparent" needed here
All of the solutions above have a problem with compatibility (works nice on one version of Android, but fails on other) - especially if you want to use transparency. The only really robust solution is to use nine-patch file.
You can download from: http://ge.tt/517ZIFC2/v/1?c
Just place the chosen png to the drawable-nodpi directory to avoid resampling.
And use it in your Adapter:
convertView.setBackgroundResource(R.drawable.border_b1px_black);
You will have to enable the rows in the isEnabled() method for Android 5.0 and higher.
But you can still disable the rows another way:
In the following example, I'm disabling every row but row 0:
In your getView method for your Adapter:
if (position > 0) {
convertView.setClickable(true);
}
For some reason setting clickable to true disables the row. I'm not sure why. I assumed at first this would make it clickable but it doesn't.
Reference: Android ListView child View setEnabled() and setClickable() do nothing
See user622689 answer.
Instead of setting isEnabled, on your ListView, set android:listSelector="#android:color/transparent"
as well as android:focusable="true" and
android:clickable="true". It gives the same effect
I can verify that when areAllItemsEnabled() returns false, then for every specific row that you want to set as non-selectable via isEnabled(int position) the line separator (divider) disappears. Setting areAllItemsEnabled() to always return true, and playing just with isEnabled(int position) should make specific rows non-selectable with the divider showing just fine.
use setDivider(Drawable divider) method of the listview
I had the same problem on Lollipop. Workaround for me was to change the background in the listview to transparent. In my case I was missing the dividers on the nav drawer on rows where isEnabled returns false when I set a background to a color. Try something like:
android:background="#android:color/transparent"
I had a similar problem. I solved it by explicitly setting the divider height of the list view to be "1dp"
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="1dp"
/>
To actually EMULATE a disabled item, in the getView of the adapter, where layout = (your return value):
if ( ! YOUR_ITEM_REF?.isEnabled()) {
layout.setClickable(true);
layout.setAlpha(0.5f);
} else {
layout.setClickable(false);
layout.setAlpha(1f);
}
This 100% works the way you would think it should, by simply disabling the item, and painting it as disabled by using a simple alpha filter to get the 'Ghost' effect.
Where YOUR_ITEM_REF is your object (item) in the list, not the adapter or the list, but the actual item.
Your adapter should return true for allItemsEnabled and isEnabled, to disable the broken default feature handling.
This is how i fixed my problem, using the answer given by Sandy D..
This does not work if your layout has a click handler set (which is not likely, but could happen through user error).
I found this Hide footer view in ListView?. As Yoni poited out correctly, you can hide a header in a ListView by wrapping it into a FrameLayout and setVisibility() of the inner View to View.GONE. This works almost perfect for me, BUT:
As the FrameLayout still exists, the ListView adds two dividers to the displayed list. It seems like a single divider with a height of two dividers. Is there a way to hide a single divider of a ListView? Maybe it's possible to change the divider's color to the background, that would be fine for me, too. Any complete other ideas? Perfect!
Please help me. I'm not keen on spending two more hours of trial and error.
Thanks a lot!
Together with hiding or showing your header or footer, use these functions:
setFooterDividersEnabled()
setHeaderDividersEnabled()
you can use xml attributes to hide divider for header and footer in ListView
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
you can change the dividers color like this:
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#android:color/transparent"
android:dividerHeight="2px"/>
For disable divider:
ListView.setDivider(null);