![](/img/trans.png)
[英]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.