Dank dextor Antwort, ich diese Antwort herausfinden konnte.
ich verwendet habe, die FocusChangeListener
und hinzugefügt Animation Staaten die Größe der Ansicht zu ändern:
static class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(final View root) {
// bind views
// ...
// bind focus listener
root.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
// run scale animation and make it bigger
Animation anim = AnimationUtils.loadAnimation(context, R.anim.scale_in_tv);
root.startAnimation(anim);
anim.setFillAfter(true);
} else {
// run scale animation and make it smaller
Animation anim = AnimationUtils.loadAnimation(context, R.anim.scale_out_tv);
root.startAnimation(anim);
anim.setFillAfter(true);
}
}
});
}
Und den Code für die anims:
scale_in_tv:
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXScale="100%"
android:fromYScale="100%"
android:toXScale="110%"
android:toYScale="110%"
android:pivotX="50%"
android:pivotY="50%">
</scale>
scale_out_tv :
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="100"
android:fromXScale="110%"
android:fromYScale="110%"
android:toXScale="100%"
android:toYScale="100%"
android:pivotX="50%"
android:pivotY="50%">
</scale>
mache ich genau das selbe. hat aber keine Auswirkung auf meine 'RecyclerList'. Ich habe eine Bildansicht auf meinem Ansichtshalter und möchte im Fokus größer sein. Hilf mir! –
Hallo @ SadeqShajary, vielleicht sollten Sie den FokusChangeListener auf die Root-Ansicht anstelle der ImageView selbst anwenden. Dies wurde entwickelt und getestet auf Android TV, mit einer Fernbedienung. – Skycorsarius
Bitte bearbeiten Sie die Lösung nicht in der Frage - Sie sollten sie als Antwort veröffentlichen, damit sie mit dem Q & A-Format von Stack Overflow übereinstimmt. – EJoshuaS