2016-04-27 8 views
3

ich mit Szenenübergängen seltsame Zeichnung Frage, die sie (mit Nexus 5-fach 6.0.1 Plattform läuft)Szene Übergang Bild in Kacheln beim Übergang gezogen

Ich fand heraus, dass <item name="android:windowBackground">@null</item> eine Beziehung zu dem Thema hat.

Wer weiß, warum dies passiert und was können mögliche Orte zu überprüfen, um dies zu beheben?

Hier ist mein Setup Testprojekt, das Problem zu reproduzieren:

minSdkVersion 16 and targetSdkVersion 23 using: 

com.android.support:appcompat-v7:23.3.0 

AndroidManifest.xml

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 

      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </activity> 
    <activity android:name=".NextActivity"/> 
</application> 

Stil s.xml

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="android:windowActionBar">false</item> 
     <item name="android:windowNoTitle">true</item> 
     <item name="android:windowBackground">@null</item> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

</resources> 

MainActivity.java

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     final View iv = findViewById(R.id.iv_test); 
     ViewCompat.setTransitionName(iv, "test"); 

     findViewById(R.id.b_go).setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this, 
         android.support.v4.util.Pair.create(iv, "test")).toBundle(); 

       startActivity(new Intent(MainActivity.this, NextActivity.class), bundle); 
      } 
     }); 
    } 
} 

NextActivity.java

public class NextActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_next); 

     final View iv = findViewById(R.id.iv_test); 
     ViewCompat.setTransitionName(iv, "test"); 
    } 
} 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.test.scenetransitions.MainActivity"> 

    <ImageView 
     android:id="@+id/iv_test" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@android:drawable/ic_dialog_email" 
     android:tint="@color/colorAccent"/> 

    <Button 
     android:id="@+id/b_go" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:background="@color/colorAccent" 
     android:padding="20dp" 
     android:text="GO"/> 
</RelativeLayout> 

activity_next.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.test.scenetransitions.MainActivity"> 

    <ImageView 
     android:id="@+id/iv_test" 
     android:layout_width="200dp" 
     android:layout_height="200dp" 
     android:layout_centerInParent="true" 
     android:src="@android:drawable/ic_dialog_email" 
     android:tint="@color/colorAccent"/> 
</RelativeLayout> 

Und hier ist Screenshot in der richtigen Zeit während des Übergangs nahm:

enter image description here

Antwort

2

Das Problem ist mit <item name="android:windowBackground">@null</item> Sie sollten nie Verwendung null für Fenster Hintergrund. Ersetzen Sie es mit <item name="android:windowBackground">@android:color/transparent</item>

Wenn Sie es auf null setzen Android weiß nicht, was zu zeichnen und es könnte jeden Müll von GPU zeichnen. Sie sollten also den transparenten Hintergrund explizit angeben.

+0

In der Tat hat das das Problem behoben. Komische Tatsache, ich habe versucht, den windowBackground zu ändern, habe mich aber nicht daran erinnert, dass ich viele Stile definiert habe, also habe ich mich nicht an die Version v21 erinnert: D – Niko

0

ich Ihren Code Kopie eingefügt, aber ich nicht bekommen irgendwelche Zeichnungsprobleme. Ich meine, wenn sich die zweite Seite öffnet, ist das Bild ein wenig verschwommen (verpixelt), was die Ursache für die geringe Größe des eigentlichen Bildes ist (wenn das der Fall ist, verwende einfach ein größeres Bild in der zweiten Aktivität). Vielleicht ist es dein Gerät. Ich habe das in Moto E2 getestet. Für mich ist der Übergang glatt, keine Zeichnungsprobleme was auch immer.

+0

Was ist die Plattformversion Ihres Geräts? – Niko

+0

Android 5.1 Lollipop –

+0

Getestet auf Lenovo K3 Hinweis, Marshmallow 6.0 gleichen Ausgang. Keine Probleme. Könnten Sie ein anderes Gerät testen und sehen, ob das Problem weiterhin besteht? –