嗨,我已经创建了自定义列表视图,我想让单元格 bg 透明/我的列表视图:
public class FlingListView extends ListView {
public FlingListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public FlingListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FlingListView(Context context) {
super(context);
}
private GestureDetector detector; //this is my detector
public void setDetector(GestureDetector detector){
this.detector = detector;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
detector.onTouchEvent(ev);
return super.onTouchEvent(ev);
}
}
xml:
<sk.zp.fling.listView.FlingListView
android:id="@+id/list_mailings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout1"
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:listSelector="@drawable/list_selector"
android:overScrollMode="always" >
</sk.zp.fling.listView.FlingListView>
选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/zp_green" android:state_pressed="true"/>
<item android:drawable="@color/zp_green" android:state_pressed="false" android:state_selected="true"/>
</selector>
列表单元格视图:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="86dp"
android:layout_gravity="left"
android:background="@android:color/transparent"
android:gravity="left" >
<TextView
android:id="@+id/cell_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="3dp"
android:layout_marginLeft="15dp"
android:background="@android:color/transparent"
android:layout_marginRight="15dp"
android:layout_marginTop="3dp"
android:gravity="center_vertical"
android:text="25.06.1997" />
<ImageView
android:id="@+id/cell_logo"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginBottom="2dp"
android:background="@android:color/transparent"
android:layout_marginRight="15dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@+id/cell_date"
android:adjustViewBounds="true"
android:layoutDirection="ltr"
android:scaleType="fitCenter"
android:src="@drawable/spp"
android:textAlignment="viewStart"
android:textDirection="ltr" />
<TextView
android:id="@+id/cell_company_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:background="@android:color/transparent"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:layout_toLeftOf="@+id/cell_arrow"
android:layout_toRightOf="@+id/cell_logo"
android:gravity="center_vertical"
android:lines="2"
android:maxLines="2"
android:text="Dodavatel a balab bluba lsnhso"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/cell_arrow"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@android:color/transparent"
android:layout_marginBottom="2dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:src="@drawable/arrow_custom" />
</RelativeLayout>
我在哪里做错了?因为它总是白色的bg。如果我更改为透明以外的任何其他颜色,它会起作用....所以它可能是黑色、棕红色但不透明:(
请帮忙