我正在嘗試使用listview中的可重複背景製作應用程序,但是我在可重複圖像之間的空格時遇到了一些麻煩。爲什麼是這樣?我該如何解決這個問題?ListView可重複背景創建空白
是否有另一種方法來創建可重複的背景?
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.event_list, parent, false);
List<Events> r = getEvent();
Events e = r.get(position);
LoaderImageView image = (LoaderImageView) row.findViewById(R.id.imageView1);
TextView tittel = (TextView) row.findViewById(R.id.textView1);
TextView ingress = (TextView) row.findViewById(R.id.textView2);
tittel.setText(e.getEventName().toString());
ingress.setText(e.getIngress().toString());
image.setImageDrawable(e.getThumbnail().toString());
Resources res = getResources();
BitmapDrawable background = (BitmapDrawable) res.getDrawable(R.drawable.almanakk_bg);
background.setTileModeY(TileMode.REPEAT);
row.setBackgroundDrawable(background);
return row;
}
Almanakk背景圖像: main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
>
</ListView>
Event_list.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@android:color/transparent">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="60dp"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<no.havis.utils.LoaderImageView
android:id="@+id/imageView1"
android:layout_width="60dp"
android:layout_height="60dp" android:layout_margin="3dp"/>
</TableLayout>
<TableLayout
android:id="@+id/tableLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#000000"/>
</TableRow>
<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#000000"/>
</TableRow>
</TableLayout>
styles.xml
<resources>
<style name="app_theme" parent="android:Theme">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:listViewStyle">@style/TransparentListView</item>
<item name="android:expandableListViewStyle">@style/TransparentExpandableListView</item>
</style>
<style name="TransparentListView" parent="@android:style/Widget.ListView">
<item name="android:cacheColorHint">@android:color/transparent</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="TransparentExpandableListView" parent="@android:style/Widget.ExpandableListView">
<item name="android:cacheColorHint">@android:color/transparent</item>
</style>
請郵寄包含列表視圖和列表項的佈局你的XML(如果您自定義它太)。而你確定,你的繪製doen't有它transperancy? – Hiral 2012-02-28 09:08:44