本文整理匯總了Java中android.graphics.drawable.AnimatedVectorDrawable類的典型用法代碼示例。如果您正苦於以下問題:Java AnimatedVectorDrawable類的具體用法?Java AnimatedVectorDrawable怎麽用?Java AnimatedVectorDrawable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AnimatedVectorDrawable類屬於android.graphics.drawable包,在下文中一共展示了AnimatedVectorDrawable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explore);
iv = (ImageView) findViewById(R.id.search);
text = (EditText) findViewById(R.id.text);
searchToBar = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_search_to_bar);
barToSearch = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_bar_to_search);
interp = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in);
duration = getResources().getInteger(R.integer.duration_bar);
// iv is sized to hold the search+bar so when only showing the search icon, translate the
// whole view left by half the difference to keep it centered
offset = -71f * (int) getResources().getDisplayMetrics().scaledDensity;
iv.setTranslationX(offset);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
animate();
}
});
}
示例2: onCreate
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open_on_phone_animation);
AmbientMode.attachAmbientSupport(this);
mAnimationCallback =
new AnimationCallback() {
@Override
public void onAnimationEnd(Drawable drawable) {
super.onAnimationEnd(drawable);
// Go back to main Dialogs screen after animation.
finish();
}
};
// Play 'swipe left' animation only once.
ImageView phoneImage = findViewById(R.id.open_on_phone_animation_image);
mAnimatedVectorDrawablePhone = (AnimatedVectorDrawable) phoneImage.getDrawable();
mAnimatedVectorDrawablePhone.registerAnimationCallback(mAnimationCallback);
mAnimatedVectorDrawablePhone.start();
}
開發者ID:googlesamples,項目名稱:android-WearAccessibilityApp,代碼行數:24,代碼來源:OpenOnPhoneAnimationActivity.java
示例3: initUi
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
private void initUi() {
initializeToolbar();
final AnimatedVectorDrawable avd2 = (AnimatedVectorDrawable) tvButton.getBackground();
tvButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tvButton.setText("Loading...");
avd2.start();
}
});
avd2.registerAnimationCallback(new Animatable2.AnimationCallback() {
@Override
public void onAnimationEnd(Drawable drawable) {
tvButton.setText("Try Again");
}
});
}
示例4: setupLogoAnim
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@TargetApi(21)
private void setupLogoAnim() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final ImageView iv = (ImageView) getActivity().findViewById(R.id.io_logo);
final AnimatedVectorDrawable logoAnim =
(AnimatedVectorDrawable) getActivity().getDrawable(
R.drawable.io_logo_social_anim);
iv.setImageDrawable(logoAnim);
logoAnim.start();
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logoAnim.start();
}
});
}
}
示例5: onBindViewHolder
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@Override
public void onBindViewHolder(final HabitViewHolder holder, int position) {
final Habit habit = habits.get(position);
holder.habitName.setText(habit.name);
holder.count.setText(String.format(Locale.getDefault(), "%d", habit.timesCompleted));
holder.timesPerDay.setText(context.getString(R.string.times_per_day, habit.timesPerDay));
holder.doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((AnimatedVectorDrawable) holder.doneButton.getDrawable()).start();
dbHelper.incrementHabit(habit.name);
Storage.incrementHabit(context, habit.name);
}
});
}
示例6: onCreate
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView mFabView = (ImageView) findViewById(R.id.fab_view);
// animate head to leaf
final AnimatedVectorDrawable faceAVD = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.face_avd);
mFabView.setImageDrawable(faceAVD);
findViewById(R.id.animate_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
faceAVD.start();
}
});
}
示例7: startOpenAnimations
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
private void startOpenAnimations() {
// Icon
AnimatedVectorDrawable menuIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(),
R.drawable.ic_menu_animated);
mFabView.setImageDrawable(menuIcon);
menuIcon.start();
// Reveal
int centerX = mFabRect.centerX();
int centerY = mFabRect.centerY();
float startRadius = getMinRadius();
float endRadius = getMaxRadius();
Animator reveal = ViewAnimationUtils
.createCircularReveal(mNavigationView,
centerX, centerY, startRadius, endRadius);
// Fade in
mNavigationMenuView.setAlpha(0);
Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 0, 1);
// Animations
AnimatorSet set = new AnimatorSet();
set.playSequentially(reveal, fade);
set.start();
}
示例8: checkEmptyOrConnection
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
public void checkEmptyOrConnection() {
if (!Utils.hasInternet(getActivity())) {
if (getAdapter().getItemCount() == 0) {
mEmpty.setVisibility(View.GONE);
mEmptyImage.setVisibility(View.VISIBLE);
if (UI.isLollipop()) {
final AnimatedVectorDrawable avd =
(AnimatedVectorDrawable) ContextCompat.getDrawable(getActivity(), R.drawable.avd_no_connection);
mEmptyImage.setImageDrawable(avd);
avd.start();
} else {
mEmptyImage.setImageResource(R.drawable.no_connection);
}
} else {
Toast.makeText(getActivity(), R.string.check_network, Toast.LENGTH_SHORT).show();
}
}
}
示例9: MovableMarker
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
/**
* The {@code mRounded} drawable is just the end state of the {@code mStaticToDynamic}
* {@link AnimatedVectorDrawable}.
* The {@code mStatic} drawable is the end state of the {@code mDynamicToStatic}
* {@link AnimatedVectorDrawable}. <br>
*
*/
public MovableMarker(Context context, boolean staticForm, MarkerGson.Marker marker) {
super(context);
mRounded = (AnimatedVectorDrawable) context.getDrawable(R.drawable.avd_marker_rounded);
mStatic = context.getDrawable(R.drawable.vd_marker_location_rounded);
mStaticToDynamic = (AnimatedVectorDrawable) context.getDrawable(R.drawable.avd_marker_location_rounded);
mDynamicToStatic = (AnimatedVectorDrawable) context.getDrawable(R.drawable.avd_marker_rounded_location);
/* Keep a reference on the model object */
mMarker = marker;
/* Init the drawable */
if (staticForm) {
initStatic();
} else {
initRounded();
}
}
示例10: checkConnectivity
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
private void checkConnectivity() {
final ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
connected = activeNetworkInfo != null && activeNetworkInfo.isConnected();
if (!connected) {
loading.setVisibility(View.GONE);
if (noConnection == null) {
final ViewStub stub = (ViewStub) findViewById(R.id.stub_no_connection);
noConnection = (ImageView) stub.inflate();
}
final AnimatedVectorDrawable avd =
(AnimatedVectorDrawable) getDrawable(R.drawable.avd_no_connection);
noConnection.setImageDrawable(avd);
avd.start();
connectivityManager.registerNetworkCallback(
new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(),
connectivityCallback);
monitoringConnectivity = true;
}
}
示例11: revealPostingProgress
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
void revealPostingProgress() {
Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting,
(int) fabPosting.getPivotX(),
(int) fabPosting.getPivotY(),
0f,
fabPosting.getWidth() / 2)
.setDuration(600L);
reveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(this));
reveal.start();
AnimatedVectorDrawable uploading =
(AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading);
if (uploading != null) {
fabPosting.setImageDrawable(uploading);
uploading.start();
}
}
示例12: checkConnectivity
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
private void checkConnectivity() {
final ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
connected = activeNetworkInfo != null && activeNetworkInfo.isConnected();
if (!connected) {
loading.setVisibility(View.GONE);
if (noConnection == null) {
final ViewStub stub = (ViewStub) findViewById(R.id.stub_no_connection);
noConnection = (ImageView) stub.inflate();
}
final AnimatedVectorDrawable avd =
(AnimatedVectorDrawable) getDrawable(R.drawable.avd_no_connection);
if (noConnection != null && avd != null) {
noConnection.setImageDrawable(avd);
avd.start();
}
connectivityManager.registerNetworkCallback(
new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(),
connectivityCallback);
monitoringConnectivity = true;
}
}
示例13: showFavoriteMovie
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@Override
public void showFavoriteMovie() {
if (!isFavorite) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AnimatedVectorDrawable emptyHeart = (AnimatedVectorDrawable)
emptyHeartConstantState.newDrawable();
fab.setImageDrawable(emptyHeart);
emptyHeart.start();
} else {
fab.setImageResource(R.drawable.heart_fill);
}
isFavorite = true;
}
}
示例14: showNonFavoriteMovie
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
@Override
public void showNonFavoriteMovie() {
if (isFavorite) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AnimatedVectorDrawable fullHeart = (AnimatedVectorDrawable)
fullHeartConstantState.newDrawable();
fab.setImageDrawable(fullHeart);
fullHeart.start();
} else {
fab.setImageResource(R.drawable.fab_heart_empty);
}
isFavorite = false;
}
}
示例15: AnimatedPinDrawable
import android.graphics.drawable.AnimatedVectorDrawable; //導入依賴的package包/類
public AnimatedPinDrawable(Context context) {
super();
Drawable collapsed = context.getDrawable(R.drawable.pin_collapsed);
Drawable expanded = context.getDrawable(R.drawable.pin_expanded);
AnimatedVectorDrawable expanding = (AnimatedVectorDrawable) context
.getDrawable(R.drawable.pin_collapsed_to_expanded_animation);
AnimatedVectorDrawable collapsing = (AnimatedVectorDrawable) context
.getDrawable(R.drawable.pin_expanded_to_collapsed_animation);
addState(STATE_SET_PRESSED, expanded, STATE_EXPANDED_ID);
addState(STATE_SET_UNPRESSED, collapsed, STATE_COLLAPSED_ID);
addTransition(STATE_COLLAPSED_ID, STATE_EXPANDED_ID, expanding, false);
addTransition(STATE_EXPANDED_ID, STATE_COLLAPSED_ID, collapsing, false);
paint.setColor(Color.BLUE);
paint.setTextSize(24f);
paint.setTextAlign(Paint.Align.CENTER);
paint.setAntiAlias(true);
duration = context.getResources().getInteger(android.R.integer.config_mediumAnimTime);
}