我知道可以在可扩展 ListView 中创建自定义组指示器。我还知道您可以使用 setIndicatorBound() 定位默认组指示器。我自己没有看到也无法实现的是将这两种效果结合起来。
有谁知道任何实际证据可以证明这些可以结合起来完成?
目前我可以创建自定义指标并移动它。但是当我使用 setIndicatorBounds 时,它总是移动到屏幕右侧的一半。检查这个Related Post
我的问题是你真的能做到这一点吗?有没有证据,因为我没有找到。
最佳答案
我使用以下教程实现了这一点:http://android-adda.blogspot.com/2011/06/custom-expandable-listview.html
关键是这段代码:
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);
}
关于java - 可扩展 ListView 您可以移动自定义图标(指示器)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7457528/