Подтвердить что ты не робот

Андроид linearlayout фон селектор

Я добавляю некоторые представления Linringayout в scrollview, раздувая их динамически. Я установил фон добавленного LinearLayout в список селекторов. Но после добавления в scrollview, когда я нажимаю выбранное представление, он не показывает никакого влияния на список селекторов. Я использую следующие XML файлы:

Селекторный файл: 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>

И я раздуваю следующий вид и добавляю к 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>

И ScrollView, к которому добавляются вышеперечисленные завышенные виды, выглядит так:

<?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>

Любая идея...???

4b9b3361

Ответ 1

Вы должны сделать LinearLayout доступным.

android:clickable="true"