android-ListView item的高度及分割线的长度

来源:互联网 发布:hex转换ascii编程 编辑:程序博客网 时间:2024/05/22 19:35

》ListView分割线的长度的一种方案:

android:divider="@null",

然后在item的底部添加一条线View,可自己控制长度。


》item高度:

在ListView Adapter的getView中去动态改变即可,关键代码:

            if (view == null) {                view = getActivity().getLayoutInflater().inflate(                        R.layout.listview_item, null);                holder = new ViewHolder();                LinearLayout ll = (LinearLayout)view.findViewById(R.id.item_layout);                holder.tvTitle = (TextView) view                        .findViewById(R.id.subject_title);                holder.imgIco = (ImageView) view.findViewById(R.id.item_ico);                LayoutParams linearParams = (LayoutParams) ll                        .getLayoutParams();
//获取屏幕的dp与sp的转化等                linearParams.height = screenWidth * 250 / 460;//                linearParams.gravity = Gravity.CENTER_VERTICAL;                ll.setLayoutParams(linearParams);                view.setTag(holder);            } else {                holder = (ViewHolder) view.getTag();            }
0 0