List of usage examples for android.view View setAlpha
public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
From source file:com.pdmanager.views.patient.TechnicianActivity.java
@Override public void onMessageReceived(final CNMessage cnMessage) { if (application.getUniqueId().equals(cnMessage.getUniqueId())) { return;//from w w w . j ava 2s . c om } if (cnMessage.getMessageType() == CNMessage.CNMessageType.Calling) { if (application.isInConference()) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.Busy, null); return; } callDialog = new AlertDialog.Builder(this).create(); LayoutInflater inflater = getLayoutInflater(); View incomingCallDialog = inflater.inflate(R.layout.incoming_call_dialog, null); incomingCallDialog.setAlpha(0.5f); callDialog.setView(incomingCallDialog); TextView caller = (TextView) incomingCallDialog.findViewById(R.id.caller); caller.setText(cnMessage.getDisplayName()); Button answerButton = (Button) incomingCallDialog.findViewById(R.id.answer_button); answerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.setConferenceId(cnMessage.getConferenceId()); application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerAccept, null); callDialog.hide(); currentRingtone.stop(); Intent intent = new Intent(application.getContext(), TechnicianActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); application.join(application.getConferenceId(), true); } }); Button declineButton = (Button) incomingCallDialog.findViewById(R.id.decline_button); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerDecline, null); currentRingtone.stop(); callDialog.hide(); } }); callDialog.setCancelable(false); callDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //play current Ringtone currentRingtone.play(); callDialog.show(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.Cancel) { currentRingtone.stop(); callDialog.hide(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.EndCall) { if (application.leave()) { int count = getFragmentManager().getBackStackEntryCount(); String name = getFragmentManager().getBackStackEntryAt(count - 2).getName(); getFragmentManager().popBackStack(name, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } }
From source file:nu.yona.app.ui.tour.YonaCarrouselActivity.java
@Override public void transformPage(View view, float position) { final int pageWidth = view.getWidth(); /*//from w w w . j a va 2 s .c o m * When a page's alpha is set to 0 it's visibility should also be set to gone. * Even though the view isn't visible it can still be interacted with if it isn't gone and is drawn on top. */ /* * Position is checked right up next to -1 and 1. The reason is because sometimes the position doesn't seem to come * all the way through as a whole number. Meaning it seems it would stop so very close to -1 or 0 (for example) and * the code to make necessary views 'gone' never gets called. So then there could be an invisible view on top that is * still able to be interacted with. */ if (position < -TRANFORMATION_POSITION) { // [-Infinity,-1) // This page is way off-screen to the left so hide it. view.setAlpha(0); view.setTranslationX(pageWidth); } else if (position <= TRANFORMATION_POSITION) { // (-1, 1) // The further the page is from being center page the more transparent it is. view.setAlpha(getAlpha(position)); // Counteract the default slide transition view.setTranslationX(pageWidth * -position); // Make sure the page is visible view.setVisibility(View.VISIBLE); } else { // (1,+Infinity] // This page is way off-screen to the right so hide it. view.setAlpha(0); view.setVisibility(View.GONE); view.setTranslationX(-pageWidth); } }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void fadeIn(View v) { v.setAlpha(0f); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(v, "alpha", 1f); alphaAnimator/* w w w.j a va2s . c o m*/ .setDuration(v.getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.start(); }
From source file:com.simplecity.amp_library.ui.views.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null;/*from w w w . j a v a2 s .c o m*/ if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); mTabViews.add(tabView); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (tabView instanceof TextView) { ((TextView) tabView).setTextColor(mTextColor); } if (i == mViewPager.getCurrentItem()) { if (tabView instanceof TextView) { tabView.setAlpha(1.0f); } } else { if (tabView instanceof TextView) { tabView.setAlpha(0.7f); } } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); if (mShouldExpand) { mTabStrip.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f)); } else { mTabStrip.addView(tabView); } } }
From source file:com.fairphone.fplauncher3.applifecycle.AgingAppsListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { AppInfo info = allApps.get(position); RelativeLayout fullIcon = (RelativeLayout) mInflater.inflate(R.layout.fp_aging_apps_item, parent, false); BubbleTextView icon = (BubbleTextView) fullIcon.findViewById(R.id.application_icon); View pinLabel = fullIcon.findViewById(R.id.label_icon_pinned); View newLabel = fullIcon.findViewById(R.id.label_icon_new); View updatedLabel = fullIcon.findViewById(R.id.label_icon_updated); icon.applyFromApplicationInfo(info); icon.setOnClickListener(mLauncher);//from ww w. ja v a 2 s.co m icon.setOnLongClickListener(mLongClickListener); icon.setOnTouchListener(null); icon.setOnKeyListener(null); icon.setOnFocusChangeListener(null); ApplicationRunInformation appRunInfo = AppDiscoverer.getInstance().getApplicationRunInformation(mContext, info.getComponentName()); if (appRunInfo != null) { if (appRunInfo.isPinnedApp()) { pinLabel.setVisibility(View.VISIBLE); } if (appRunInfo.isUpdatedApp()) { updatedLabel.setVisibility(View.VISIBLE); } else if (appRunInfo.isNewApp()) { newLabel.setVisibility(View.VISIBLE); } } if (isUnusedApp) { Drawable icd = icon.getCompoundDrawables()[1]; // 1 is top if (icd != null) { int alpha = mContext.getResources().getInteger(R.integer.color_alpha_70_percent); icd.setAlpha(alpha); updatedLabel.setAlpha(alpha); newLabel.setAlpha(alpha); } } return fullIcon; }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
public void setLowProfile(final boolean lightsOut, final boolean animate, final boolean force) { if (!force && lightsOut == mLowProfile) return;/* w ww. j a v a2s. c o m*/ mLowProfile = lightsOut; if (DEBUG) Slog.d(TAG, "setting lights " + (lightsOut ? "out" : "on")); final View navButtons = mCurrentView.findViewById(R.id.nav_buttons); final View lowLights = mCurrentView.findViewById(R.id.lights_out); // ok, everyone, stop it right there navButtons.animate().cancel(); lowLights.animate().cancel(); if (!animate) { navButtons.setAlpha(lightsOut ? 0f : 1f); lowLights.setAlpha(lightsOut ? 1f : 0f); lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE); } else { navButtons.animate().alpha(lightsOut ? 0f : 1f).setDuration(lightsOut ? 750 : 250).start(); lowLights.setOnTouchListener(mLightsOutListener); if (lowLights.getVisibility() == View.GONE) { lowLights.setAlpha(0f); lowLights.setVisibility(View.VISIBLE); } lowLights.animate().alpha(lightsOut ? 1f : 0f).setDuration(lightsOut ? 750 : 250) .setInterpolator(new AccelerateInterpolator(2.0f)) .setListener(lightsOut ? null : new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator _a) { lowLights.setVisibility(View.GONE); } }).start(); } }
From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java
private void loadOtherRowAnimator() { final AnimatorUpdateListener updateListener = new AnimatorUpdateListener() { @Override// w w w . j a va 2s .c om public void onAnimationUpdate(ValueAnimator arg0) { if (getVerticalGridView() == null) { return; } final float fraction = (Float) arg0.getAnimatedValue(); final int count = getVerticalGridView().getChildCount(); for (int i = 0; i < count; i++) { View view = getVerticalGridView().getChildAt(i); if (getVerticalGridView().getChildAdapterPosition(view) > 0) { view.setAlpha(fraction); view.setTranslationY((float) mAnimationTranslateY * (1f - fraction)); } } } }; Context context = getContext(); mOtherRowFadeInAnimator = loadAnimator(context, R.animator.lb_playback_controls_fade_in); mOtherRowFadeInAnimator.addUpdateListener(updateListener); mOtherRowFadeInAnimator.setInterpolator(mLogDecelerateInterpolator); mOtherRowFadeOutAnimator = loadAnimator(context, R.animator.lb_playback_controls_fade_out); mOtherRowFadeOutAnimator.addUpdateListener(updateListener); mOtherRowFadeOutAnimator.setInterpolator(new AccelerateInterpolator()); }
From source file:com.grottworkshop.gwsmaterialcalendarview.MaterialCalendarView.java
@SuppressWarnings("deprecation") public MaterialCalendarView(Context context, AttributeSet attrs) { super(context, attrs); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //If we're on good Android versions, turn off clipping for cool effects setClipToPadding(false);// www. j a v a 2 s . c o m setClipChildren(false); } else { //Old Android does not like _not_ clipping view pagers, we need to clip setClipChildren(true); setClipToPadding(true); } buttonPast = new DirectionButton(getContext()); title = new TextView(getContext()); buttonFuture = new DirectionButton(getContext()); pager = new ViewPager(getContext()); setupChildren(); title.setOnClickListener(onClickListener); buttonPast.setOnClickListener(onClickListener); buttonFuture.setOnClickListener(onClickListener); titleChanger = new TitleChanger(title); titleChanger.setTitleFormatter(DEFAULT_TITLE_FORMATTER); adapter = new MonthPagerAdapter(); adapter.setTitleFormatter(DEFAULT_TITLE_FORMATTER); pager.setAdapter(adapter); pager.setOnPageChangeListener(pageChangeListener); pager.setPageTransformer(false, new ViewPager.PageTransformer() { @Override public void transformPage(View page, float position) { position = (float) Math.sqrt(1 - Math.abs(position)); page.setAlpha(position); } }); adapter.setCallbacks(monthViewCallbacks); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialCalendarView, 0, 0); try { int tileSize = a.getDimensionPixelSize(R.styleable.MaterialCalendarView_mcv_tileSize, -1); if (tileSize > 0) { setTileSize(tileSize); } setArrowColor(a.getColor(R.styleable.MaterialCalendarView_mcv_arrowColor, Color.BLACK)); Drawable leftMask = a.getDrawable(R.styleable.MaterialCalendarView_mcv_leftArrowMask); if (leftMask == null) { //TODO: getDrawable depreciated leftMask = getResources().getDrawable(R.drawable.mcv_action_previous); } setLeftArrowMask(leftMask); Drawable rightMask = a.getDrawable(R.styleable.MaterialCalendarView_mcv_rightArrowMask); if (rightMask == null) { //TODO: getDrawable depreciated rightMask = getResources().getDrawable(R.drawable.mcv_action_next); } setRightArrowMask(rightMask); setSelectionColor( a.getColor(R.styleable.MaterialCalendarView_mcv_selectionColor, getThemeAccentColor(context))); CharSequence[] array = a.getTextArray(R.styleable.MaterialCalendarView_mcv_weekDayLabels); if (array != null) { setWeekDayFormatter(new ArrayWeekDayFormatter(array)); } array = a.getTextArray(R.styleable.MaterialCalendarView_mcv_monthLabels); if (array != null) { setTitleFormatter(new MonthArrayTitleFormatter(array)); } setHeaderTextAppearance(a.getResourceId(R.styleable.MaterialCalendarView_mcv_headerTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_Header)); setWeekDayTextAppearance(a.getResourceId(R.styleable.MaterialCalendarView_mcv_weekDayTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_WeekDay)); setDateTextAppearance(a.getResourceId(R.styleable.MaterialCalendarView_mcv_dateTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_Date)); setShowOtherDates(a.getBoolean(R.styleable.MaterialCalendarView_mcv_showOtherDates, false)); int firstDayOfWeek = a.getInt(R.styleable.MaterialCalendarView_mcv_firstDayOfWeek, -1); if (firstDayOfWeek < 0) { firstDayOfWeek = CalendarUtils.getInstance().getFirstDayOfWeek(); } setFirstDayOfWeek(firstDayOfWeek); } catch (Exception e) { e.printStackTrace(); } finally { a.recycle(); } currentMonth = CalendarDay.today(); setCurrentDate(currentMonth); if (isInEditMode()) { removeView(pager); MonthView monthView = new MonthView(context, currentMonth, getFirstDayOfWeek()); monthView.setSelectionColor(getSelectionColor()); monthView.setDateTextAppearance(adapter.getDateTextAppearance()); monthView.setWeekDayTextAppearance(adapter.getWeekDayTextAppearance()); monthView.setShowOtherDates(getShowOtherDates()); addView(monthView, new LayoutParams(MonthView.DEFAULT_MONTH_TILE_HEIGHT)); } }
From source file:net.quduo.pixel.interfaces.android.widget.FragmentViewPager.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void animateStack(View left, View right, float effectOffset, int positionOffsetPixels) { /*/* w w w . j a v a 2 s .c om*/ if (right != null) { // ? ???0.0~1.0?? // ???1.0~0?? mScale = (1 - SCALE_MAX) * effectOffset + SCALE_MAX; // x??? ???0-720 ???720-0 mTrans = -getWidth() - getPageMargin() + positionOffsetPixels; ViewHelper.setScaleX(right, mScale); ViewHelper.setScaleY(right, mScale); ViewHelper.setTranslationX(right, mTrans); } if (left != null) { left.bringToFront(); } */ // Make sure we're running on HONEYCOMB or higher to use APIs if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (left != null && right != null) { if (DEBUG) Log.d(TAG, "effectOffset:" + effectOffset); left.setAlpha(1 - effectOffset); right.setAlpha(effectOffset); } } }
From source file:com.serenegiant.aceparrot.BaseFragment.java
/** * 01??(View)??// w w w. j a va 2 s. c o m * @param target * @param startDelay */ @SuppressLint("NewApi") protected final void zoomIn(final View target, final long duration, final long startDelay) { // if (DEBUG) Log.v(TAG, "zoomIn:target=" + target); if (target == null) return; target.clearAnimation(); target.setVisibility(View.VISIBLE); target.setTag(R.id.anim_type, ANIM_ZOOM_IN); // ??? target.setScaleX(0.0f); target.setScaleY(0.0f); target.setAlpha(1.0f); final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat("scaleX", 0.01f, 1f); final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat("scaleY", 0.01f, 1f); final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y); objectAnimator.addListener(mAnimatorListener); if (BuildCheck.isJellyBeanMR2()) objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator???? objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5??? objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ??? objectAnimator.start(); // }