开发者

android linearlayout background selector

I am adding some Linearlayout views in a scrollview by inflating them dynamically. I have set the background of the added LinearLayout to a selector list. But after adding to scrollview, when I press the selected view, it does not show any affect of selector list. The example XMLs I am using are:

Selector file: selector_file

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/listbg"
      android:state_pressed="true" />
<item android:drawable="@drawable/bgsmall"/>
</selector>

And I am inflating the following view and adding to l1 Linearlayout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_file"
android:gravity="center_vertical"
>
<ImageView android:id="@+id/image1" android:layout_width="100dip" android:layout_height="75dip"/>
<TextView android:id="@+id/textitem" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000"></TextView>
</LinearLayout>

And the ScrollView to which the开发者_开发技巧 above inflated views are being added is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>

<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
    <LinearLayout android:id="@+id/l1"  android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">

</LinearLayout>
</ScrollView>
</LinearLayout>

Any Idea...???


You must make the LinearLayout clickable.

android:clickable="true"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜