Reputation: 20348
I've two ListView
s in a single LinearLayout
. The background of LinearLayout is a drawable. Everything is working fine, but when I do fling on any of the ListView, the background image disappears and the black background is shown. When fling stops the image gets shown again as a background. I don't want to change the background, Am I doing anything wrong?
The Layout is as following:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:text="Upcoming Trips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/top_blue_box"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="16sp"
android:layout_gravity="center"
/>
<ListView
android:id="@+id/upList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
/>
<TextView
android:text="Past Trips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bottom_box"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="16sp"
android:layout_gravity="center_horizontal"
/>
<ListView
android:id="@+id/downList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
/>
</LinearLayout>
EDIT: The solution is explained here in details, thanks to Robinhood.
Upvotes: 2
Views: 700
Reputation: 10969
Apply same color cache hint to listview as your layout color.
Example:
android:cacheColorHint="light blue"
Upvotes: 2
Reputation: 37729
use
listView.setCacheColorHint(Color.TRANSPARENT);
in java or
android:cacheColorHint="#00000000"
inside ListView tag in xml
Upvotes: 4