[英]Set margin to a listview item, without affectin margin of whole listview
[英]listview - set negative margin for item of listview programmatically
我对属于listview的项目的视图进行负边距处理时遇到问题。
我的物品看起来像这样:
我想举第二项,第三项,依此类推。 最终效果应如下所示
我尝试了setTop
方法。
private class MyCustomAdapter extends ArrayAdapter<Integer> {
public MyCustomAdapter()
{
super(ListOfBeaconPlaces.this, R.layout.list_of_places_item_view, drawables);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View takenView = convertView;
if (takenView == null)
{
takenView = getLayoutInflater().inflate(R.layout.list_of_places_item_view, null, false);
}
final CuttedImageView cuttedImage = (CuttedImageView) takenView.findViewById(R.id.list_item_view);
cuttedImage.setImageResource(drawables.get(position));
if (cuttedImage.getHeightOfDrawnTransparentTriangle() != 0)
{
cuttedImage.setTop( (int)-cuttedImage.getHeightOfDrawnTransparentTriangle());
}
return takenView;
}
}
CuttedImageView
是我的自定义类,它继承自ImageView
在我第一次在布局上绘制后就知道了这个三角形的高度,但这不是问题。 我尝试使用LayoutParameters,但对我来说也不起作用。
是否有可能使整个商品的利润率变为负数?
我看到了一个问题,该问题涉及在linearlayout或相对布局中或在listview的项目内部设置项目的边距,但是在更改整个项目的边距时我找不到任何东西。
在xml文件的listview中,将分隔线高度设置为负数以得到重叠效果。
像这样
android:dividerHeight="-10.0dp"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.