Expandable Listview Can You Move a Custom Icon ( indicator )?
I know it is possible to create a custom group indicator in an expandable listview. I also know that you can position the default group indicator by using setIndicatorBound(). What I have not seen and been unable to achieve myself is to combine these two effects.
Does anyone know of any actual proof that these are able to be done in conjunction?
At the moment I can create a custom indicator and move it. But when I use开发者_StackOverflow中文版 setIndicatorBounds it always moves to half way off the screen on the right. Check this Related Post
My question is can you actually achieve this? Is there proof anywhere as I have found none.
I achieved this using following tutorial: http://android-adda.blogspot.com/2011/06/custom-expandable-listview.html
The key is this code:
DisplayMetrics metrics = new DisplayMetrics();
ExpandableListView expList = getExpandableListView();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
//this code for adjusting the group indicator into right side of the view
expList.setIndicatorBounds(width - GetDipsFromPixel(50), width -
public int GetDipsFromPixel(float pixels)
{
// Get the screen's density scale
final float scale = getResources().getDisplayMetrics().density;
// Convert the dps to pixels, based on density scale
return (int) (pixels * scale + 0.5f);
}
精彩评论