我想我的手,在Android的SharedElements和内容转换。我试图结合内容转换和共享元素,并创造出一种特殊的动画,但是我也遇到了问题。在共享的元素(ImageView的)结束转场之后,我使用的内容转换为动画文本查看到使用幻灯片切换位置。然而,当textViews从底部滑动到自己的位置上的图像视图顶部,文云的ImageView的(共享元)之下,后来只是出现在ImageView的顶部。有没有办法做到这一点吗?
I am trying my hands with SharedElements and Content Transitions in Android. I was trying to combine Content Transitions and Shared Elements and create a particular animation, however I have encountered a problem. After the transition on Shared Elements (ImageView) end, I am using content Transitions to animate Text View into position using Slide Transition. However when the textViews are sliding from Bottom to their position on the top of image View, the text goes beneath the ImageView (Shared Element) and later just appears on the top of the ImageView. Is there a way to do this right?
我与一些截图它解释这里分享一个简短code:
I am sharing a short code here with some screenshots which explain this:
Activity_A.java
Activity_A.java
package com.example.mehulp.sharedelementsviewheirarchy;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class Activity_a extends Activity {
ImageView imageView_a;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_a);
imageView_a = (ImageView) findViewById(R.id.imgView_a);
imageView_a.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageClickListener();
}
});
}
private void imageClickListener() {
Intent intent = new Intent(Activity_a.this, Activity_b.class);
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this, imageView_a, imageView_a.getTransitionName()).toBundle());
}
}
activity_a.xml
activity_a.xml
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:id="@+id/imgView_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:transitionName="fImage"
android:padding="30dp"
android:src="@drawable/female_result"/>
<LinearLayout
android:id="@+id/ll_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignBottom="@id/imgView_a">
<TextView
android:id="@+id/myName_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MyName: Lorem Ipsum Ipsum"
android:padding="10dp"/>
<TextView
android:id="@+id/myAge_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My Age: abc years, xyz months, pqr days"
android:padding="10dp"/>
</LinearLayout>
</RelativeLayout>
Activity_B.java
Activity_B.java
package com.example.mehulp.sharedelementsviewheirarchy;
import java.util.List;
public class Activity_b extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_b);
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
TransitionSet transitionSet = new TransitionSet();
transitionSet.setDuration(3000);
Slide slideFromBottom = new Slide(Gravity.BOTTOM);
slideFromBottom.addTarget(R.id.myAge_b);
slideFromBottom.addTarget(R.id.myName_b);
transitionSet.addTransition(slideFromBottom);
getWindow().setEnterTransition(transitionSet);
super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots);
}
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);
}
});
}}
activity_b.xml
activity_b.xml
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/imgView_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:transitionName="fImage"
android:padding="30dp"
android:scaleType="fitXY"
android:src="@drawable/female_result"/>
<LinearLayout
android:id="@+id/ll_b"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/myName_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MyName: Lorem Ipsum Ipsum"
android:padding="10dp"/>
<TextView
android:id="@+id/myAge_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My Age: abc years, xyz months, pqr days"
android:padding="10dp"/>
</LinearLayout>
我kindof找到了解决类似的问题,在这里:Android共享视图转型淡出过渡结合
I kindof found a solution to a similar problem, here: Android shared view transition combined with fade transition
总之,我禁用覆盖共享的元素,如上建议。然后,我取消了对活动的背景(用透明的主题)。见我的答案,也许它会帮助你(我想这你现在提出的)。
In short, I disabled overlay for shared elements, as suggested above. Then i removed the background on the Activity (by using a transparent theme). See my answer, maybe it would have helped you (I assume this you have moved on by now).
上一篇:序列化在.NET考虑streamsize限制序列化、NET、streamsize
下一篇:string.IsNullOrEmpty()似乎并不在类中的处理字符串类中类中、字符串、string、IsNullOrEmpty