Android listSelector noch teilweise sichtbar, wenn das Element herausgescrollt wird
Das Bild zeigt das Problem:Venus
Element ist herausgerollt, aber die Auswahl ist sichtbar.
Ich habe @ angeschaHanged listSelector in ListView und ich benutze Formen / Farbverlauf, wie es empfohlen wurde, aber immer noch kein Glück.
Gerät: MS VS Emulator für Android, Android 4.2 XHDPI API-17
IDE: Android Studio 2. unter Windows 7 WM.
Layout, Hauptaktivität
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
android:drawSelectorOnTop="false"
android:scrollingCache="false"
android:animationCache="false"
android:listSelector="@drawable/list_selector">
</ListView>
</LinearLayout>
list selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/item_pressed" />
<item
android:drawable="@drawable/item_selected" />
</selector>
drawables, item_pressed
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#0000ff"
android:startColor="#0000ff" />
</shape>
item_selected
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#00ff00"
android:startColor="#00ff00" />
</shape>
Und Aktivitätscode
package com.example.listdemo;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.Planets, R.layout.myitem);
setListAdapter(adapter);
}
}
woPlanets
ist nur eine Reihe von Zeichenfolgen (Sonne, Merkur, Venus, Erde, Mars, Jupiter ...) undmyitem
ist nur einTextView
mit benutzerdefinierter Höhe.
Wo irre ich mich bitte?
BEARBEITE Um die Frage zu klären, geht es um das Standardverhalten bei der Listenauswahl. Es geht um einen Listenauswahlpunkt ohneandroid:state_xxx
Attribute. Achten Sie nicht besonders auf den entsprechenden Namen. Ich bin bereit, @ umzubenenn@drawable/item_selected
zu@drawable/item_default
. Lassen Sie mich wissen, ob dies zur Klärung des Problems beiträgt, und ich werde es umbenennen.