本文整理匯總了Java中android.support.v4.view.ViewCompat.getTransitionName方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewCompat.getTransitionName方法的具體用法?Java ViewCompat.getTransitionName怎麽用?Java ViewCompat.getTransitionName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.getTransitionName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onClick
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public void onClick(View view) {
Intent intent = new Intent(this, SharedElementSecondActivity.class);
// startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this, firstSharedView, "sharedView").toBundle());
/* 要實現這種共享元素的過渡,那麽就需要在兩個布局對應的 view 中指定相同的 android:transitionName=""
* 有多個 View 需要過渡就需要用到 Pair 來將 view 和 transitionName 對應起來
* */
Pair first = new Pair<>(mFirstSharedView, ViewCompat.getTransitionName(mFirstSharedView));
Pair second = new Pair<>(mSecondSharedView, ViewCompat.getTransitionName(mSecondSharedView));
ActivityOptionsCompat transitionActivityOptions =
ActivityOptionsCompat.makeSceneTransitionAnimation(
this, first, second);
ActivityCompat.startActivity(this,
intent, transitionActivityOptions.toBundle());
}
示例2: launch
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public static void launch(AppCompatActivity activity, View transitionView, int resId) {
// Intent intent = new Intent(activity, ViewerActivity.class);
//
//
// ActivityOptionsCompat options = ActivityOptionsCompat
// .makeSceneTransitionAnimation(activity, transitionView, "image");
//
// ActivityCompat.startActivity(activity, intent, options.toBundle());
Pair squareParticipant = new Pair<>(transitionView, ViewCompat.getTransitionName(transitionView));
ActivityOptionsCompat transitionActivityOptions =
ActivityOptionsCompat.makeSceneTransitionAnimation(
activity, squareParticipant);
Intent intent = new Intent(
activity, ViewerActivity.class);
intent.putExtra("resId", resId);
activity.startActivity(intent, transitionActivityOptions.toBundle());
}
示例3: launch
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void launch(AppCompatActivity activity, View transitionView, int resId) {
Pair squareParticipant = new Pair<>(transitionView, ViewCompat.getTransitionName(transitionView));
ActivityOptionsCompat transitionActivityOptions =
ActivityOptionsCompat.makeSceneTransitionAnimation(
activity, squareParticipant);
Intent intent = new Intent(
activity, ViewerActivity.class);
intent.putExtra("resId", resId);
startActivity(intent, transitionActivityOptions.toBundle());
}
示例4: onMapSharedElements
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
if (!mSharedElementViews.isEmpty()) {
removeObsoleteElements(names, sharedElements, mapObsoleteElements(names));
for (View sharedElementView : mSharedElementViews) {
String transitionName = ViewCompat.getTransitionName(sharedElementView);
names.add(transitionName);
sharedElements.put(transitionName, sharedElementView);
}
}
}
示例5: create
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public static DetailsKey create(Pair<View, String> sharedElement, @IntRange(from = 1, to = 6) int kittenNumber) {
DetailsKey detailsKey = new AutoValue_DetailsKey(ViewCompat.getTransitionName(sharedElement.first), kittenNumber);
detailsKey.sharedElement = Pair.create(new WeakReference<>(sharedElement.first),
sharedElement.second); // see https://github.com/google/auto/blob/4016d8dbbe4de668a1849e95223d1f2447b647bc/value/userguide/howto.md#ignore
return detailsKey;
}
示例6: startSharedTransitionActivity
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
* Starts a shared transition of activities connected by views
* <br/>
*
* @param base The calling activity
* @param target The view from the calling activity with transition name
* @param data Intent with bundle and or activity to start
*/
public static void startSharedTransitionActivity(Activity base, View target, Intent data) {
Pair participants = new Pair<>(target, ViewCompat.getTransitionName(target));
ActivityOptionsCompat transitionActivityOptions =
ActivityOptionsCompat.makeSceneTransitionAnimation(
base, participants);
ActivityCompat.startActivity(base, data, transitionActivityOptions.toBundle());
}