List of usage examples for android.widget LinearLayout setAlpha
public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
From source file:com.tomeokin.example.jotablayout.TabLayoutActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tablayout); mViewPager = (ViewPager) findViewById(R.id.viewPager); mTabLayout = (JoTabLayout) findViewById(R.id.tabLayout); final JoTabLayout tabLayout1 = (JoTabLayout) findViewById(R.id.tabLayout1); final JoTabLayout tabLayout2 = (JoTabLayout) findViewById(R.id.tabLayout2); final JoTabLayout tabLayout3 = (JoTabLayout) findViewById(R.id.tabLayout3); for (int i = 0; i < mTabLayout.getTabCount(); i++) { mFragments.add(ContentFragment.newInstance("FrameLayout 2 ", i)); }//from ww w . ja v a2 s.c om // ?? JoTabLayout ViewPager JoTabLayout ? // tab Bounce ? OnTabSelectedListener listener = new OnTabSelectedListener() { @Override public void onTabSelect(View view, int position) { // Snackbar.make(view, "onTabSelect", Snackbar.LENGTH_SHORT).show(); if (mViewPager != null) { mViewPager.setCurrentItem(position, false); } } @Override public void onTabReselect(View view, int position) { // Snackbar.make(view, "onTabReselect", Snackbar.LENGTH_SHORT).show(); } }; mTabLayout.setOnTabSelectedListener(new OnTabSelectedListener() { @Override public void onTabSelect(View view, int position) { if (mViewPager != null) { mViewPager.setCurrentItem(position, false); } setCurrentFragment(position); } @Override public void onTabReselect(View view, int position) { } }); tabLayout1.setOnTabSelectedListener(listener); tabLayout2.setOnTabSelectedListener(listener); tabLayout3.setOnTabSelectedListener(listener); mTabLayout.applyConfigurationWithViewPager(mViewPager, false); tabLayout1.applyConfigurationWithViewPager(mViewPager, false); tabLayout2.applyConfigurationWithViewPager(mViewPager, true); tabLayout3.applyConfigurationWithViewPager(mViewPager, true); //mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { // @Override // public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // //mTabLayout.scrollTabTo(position, positionOffset); // //mTabLayout.scrollIndicatorTo(position, positionOffset); // // tabLayout1.scrollIndicatorTo(position, positionOffset); // tabLayout2.scrollTabTo(position, positionOffset); // tabLayout3.scrollTabTo(position, positionOffset); // tabLayout3.scrollIndicatorTo(position, positionOffset); // } // // @Override // public void onPageSelected(int position) { // // Log.i("take", "onPageSelected"); // mTabLayout.setCurrentTab(position); // tabLayout1.setCurrentTab(position); // tabLayout2.setCurrentTab(position); // tabLayout3.setCurrentTab(position); // } // // @Override // public void onPageScrollStateChanged(int state) { // //mTabLayout.updateState(); // // tabLayout1.updateState(); // tabLayout3.updateState(); // } //}); mViewPager.setAdapter(new MainAdapter(getSupportFragmentManager())); mViewPager.setCurrentItem(1); // mViewPager.setCurrentItem(0); ? onPageSelected ? // ?? 0 onPageSelected mTabLayout.setCurrentTab(1); setCurrentFragment(1); tabLayout1.setCurrentTab(0); tabLayout2.setCurrentTab(0); tabLayout3.setCurrentTab(0); TextView textView = new TextView(this); textView.setAlpha(1); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setAlpha(1); }
From source file:kr.co.cashqc.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (introFlag) { startActivity(new Intent(this, IntroActivity.class)); introFlag = false;/*from w ww . j av a 2s . com*/ } GoogleAnalytics.getInstance(getApplicationContext()).dispatchLocalHits(); CashqApplication c = new CashqApplication(); Tracker t = c.getTracker(CashqApplication.TrackerName.APP_TRACKER); t.setScreenName("MainActivity"); t.send(new HitBuilders.AppViewBuilder().build()); LinearLayout ll = (LinearLayout) findViewById(R.id.gps_layout); if (Build.VERSION.SDK_INT > 10) { ll.setAlpha(0.5f); } mManualTextView = (TextView) findViewById(R.id.manual_location); mContext = getApplicationContext(); // activity killer activity add. killer.addActivity(this); if (!Util.isOnline(this)) { Util.showDialog_normal(this, "? ?", "? ? ?"); } getRegId(); setHttpRequest(); new kr.co.cashqc.gcm.Timer(new TimerListener() { public void onTick() { setHttpRequest(); } }, 3000); // custom dialog init. mDialog = new CustomDialog(this); // main bg init. mLinearLayout = (LinearLayout) findViewById(R.id.bg_main); // circle menu init. CircleLayout mCircleMenu = (CircleLayout) findViewById(R.id.main_circle_layout); mCircleMenu.setOnItemSelectedListener(this); mCircleMenu.setOnItemClickListener(this); mCircleMenu.setOnRotationFinishedListener(this); mCircleMenu.setOnCenterClickListener(this); // address field init. mAddressText = (TextView) findViewById(R.id.location_name1); // gps util init. mLocationUtil = LocationUtil.getInstance(MainActivity.this); mLatitude = getIntent().getDoubleExtra("lat", -1); mLongitude = getIntent().getDoubleExtra("lng", -1); if (!mGpsFlag && mLatitude == -1) { findLocation(); } else { mGpsFlag = true; mAddressText.setText(mLocationUtil.getAddress(mLatitude, mLongitude)); } // if(adminFlag) { mManualTextView.setVisibility(View.VISIBLE); // } else { // mManualTextView.setVisibility(View.GONE); // } // gps btn set listener. findViewById(R.id.btn_gps).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { findLocation(); } }); findViewById(R.id.admin).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialog(0); } }); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build(); ImageLoader.getInstance().init(config); mIntent = new Intent(this, ShopListActivity.class); mPointText = (TextView) findViewById(R.id.display); // ? ? // new JSONParseTask().execute(); // ? }
From source file:net.hyx.app.volumenotification.adapter.ListViewAdapter.java
@Override public void onBindViewHolder(final ItemViewHolder holder, int position) { VolumeControl item = model.parseItem(items.get(position)); View itemView = holder.itemView; LinearLayout itemWrapper = (LinearLayout) itemView.findViewById(R.id.list_item_wrapper); ImageView itemHandle = (ImageView) itemView.findViewById(R.id.list_item_handle); ImageView itemIcon = (ImageView) itemView.findViewById(R.id.list_item_icon); TextView itemLabel = (TextView) itemView.findViewById(R.id.list_item_label); TextView itemHint = (TextView) itemView.findViewById(R.id.list_item_hint); itemIcon.setImageResource(model.getIconDrawable(item.icon)); itemLabel.setText(item.label);// w ww . ja v a 2 s. co m itemHint.setText(model.getDefaultLabel(item.id)); if (item.status == 0) { itemWrapper.setAlpha(ALPHA_DISABLED); } itemHandle.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { dragStartListener.onStartDrag(holder); } return true; } }); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context context = v.getContext(); int position = holder.getAdapterPosition(); Intent intent = new Intent(context, ItemViewActivity.class); VolumeControl item = items.get(position); intent.putExtra(EXTRA_ITEM, item); context.startActivity(intent); } }); }
From source file:org.mythtv.client.ui.BackendStatusFragment.java
private void animateCardLinearLayout(final LinearLayout linearLayout, long startDelay) { linearLayout.setAlpha(1); // animator that translates linearlayout AnimatorUpdateListener translationAnimatorListener = new AnimatorUpdateListener() { /* (non-Javadoc) * @see android.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(android.animation.ValueAnimator) *//*from ww w .java 2s . c om*/ @Override public void onAnimationUpdate(ValueAnimator animation) { Float w = (Float) animation.getAnimatedValue(); linearLayout.setTranslationY(w); } }; ValueAnimator scaleAnimator = ValueAnimator.ofFloat(linearLayout.getTranslationY(), 0f); scaleAnimator.setDuration(500); scaleAnimator.setRepeatCount(0); scaleAnimator.setStartDelay(startDelay); scaleAnimator.addUpdateListener(translationAnimatorListener); scaleAnimator.start(); }
From source file:com.numix.calculator.EventListener.java
private void deleteAnimation(View view) { final TextView colorLayout = (TextView) view.getRootView().findViewById(R.id.deleteColor); final LinearLayout displayView = (LinearLayout) view.getRootView().findViewById(R.id.displayLayout); final CalculatorDisplay calculatorDisplay = (CalculatorDisplay) view.getRootView() .findViewById(R.id.display); int finalRadius = Math.max(displayView.getWidth(), displayView.getHeight()); // create the animator for this view (the start radius is zero) Animator colorAnim;//from w w w . java2s.c o m colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) displayView.getRight(), (int) displayView.getBottom(), 0, finalRadius); final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f); final AlphaAnimation fadeDisplay = new AlphaAnimation(1.0f, 0.0f); fadeAnim.setDuration(250); fadeAnim.setInterpolator(new AccelerateInterpolator()); fadeAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { colorLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); fadeDisplay.setDuration(250); fadeDisplay.setInterpolator(new AccelerateInterpolator()); fadeDisplay.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mHandler.onClear(); displayView.setAlpha(1.0f); } @Override public void onAnimationRepeat(Animation animation) { } }); colorAnim.setInterpolator(new AccelerateInterpolator()); colorAnim.addListener(new android.animation.Animator.AnimatorListener() { @Override public void onAnimationStart(android.animation.Animator animation) { calculatorDisplay.startAnimation(fadeDisplay); } @Override public void onAnimationRepeat(android.animation.Animator animation) { } @Override public void onAnimationEnd(android.animation.Animator animation) { colorLayout.startAnimation(fadeAnim); } @Override public void onAnimationCancel(android.animation.Animator animation) { } }); colorLayout.setVisibility(View.VISIBLE); colorAnim.start(); }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
/** * Shows LocalImageFragment to view images * * @param view source card which was selected * @param index position of source in listAdapter *///www . ja va 2 s. c o m private void showViewImageFragment(final View view, final int index) { sourceList.setOnItemClickListener(null); sourceList.setEnabled(false); listAdapter.saveData(); Source item = listAdapter.getItem(index); String type = item.getType(); String directory; if (type.equals(AppSettings.FOLDER)) { directory = item.getData().split(AppSettings.DATA_SPLITTER)[0]; } else { directory = AppSettings.getDownloadPath() + "/" + item.getTitle() + " " + AppSettings.getImagePrefix(); } Log.i(TAG, "Directory: " + directory); final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container); final ImageView sourceImage = (ImageView) view.findViewById(R.id.source_image); final View imageOverlay = view.findViewById(R.id.source_image_overlay); final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title); final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container); final float viewStartHeight = sourceContainer.getHeight(); final float viewStartY = view.getY(); final float overlayStartAlpha = imageOverlay.getAlpha(); final float listHeight = sourceList.getHeight(); Log.i(TAG, "listHeight: " + listHeight); Log.i(TAG, "viewStartHeight: " + viewStartHeight); final LocalImageFragment localImageFragment = new LocalImageFragment(); Bundle arguments = new Bundle(); arguments.putString("view_path", directory); localImageFragment.setArguments(arguments); Animation animation = new Animation() { private boolean needsFragment = true; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (needsFragment && interpolatedTime >= 1) { needsFragment = false; getFragmentManager().beginTransaction() .add(R.id.content_frame, localImageFragment, "image_fragment").addToBackStack(null) .setTransition(FragmentTransaction.TRANSIT_NONE).commit(); } ViewGroup.LayoutParams params = sourceContainer.getLayoutParams(); params.height = (int) (viewStartHeight + (listHeight - viewStartHeight) * interpolatedTime); sourceContainer.setLayoutParams(params); view.setY(viewStartY - interpolatedTime * viewStartY); deleteButton.setAlpha(1.0f - interpolatedTime); viewButton.setAlpha(1.0f - interpolatedTime); editButton.setAlpha(1.0f - interpolatedTime); sourceTitle.setAlpha(1.0f - interpolatedTime); imageOverlay.setAlpha(overlayStartAlpha - overlayStartAlpha * (1.0f - interpolatedTime)); sourceExpandContainer.setAlpha(1.0f - interpolatedTime); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } @Override public void onAnimationRepeat(Animation animation) { } }); ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getDialogColor(appContext), getResources().getColor(AppSettings.getBackgroundColorResource())); cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue()); } }); DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f); animation.setDuration(INFO_ANIMATION_TIME); cardColorAnimation.setDuration(INFO_ANIMATION_TIME); animation.setInterpolator(decelerateInterpolator); cardColorAnimation.setInterpolator(decelerateInterpolator); needsListReset = true; cardColorAnimation.start(); view.startAnimation(animation); }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
private void startEditFragment(final View view, final int position) { sourceList.setOnItemClickListener(null); sourceList.setEnabled(false);/*from w w w . j av a2s . co m*/ listAdapter.saveData(); Source dataItem = listAdapter.getItem(position); final SourceInfoFragment sourceInfoFragment = new SourceInfoFragment(); sourceInfoFragment.setImageDrawable(((ImageView) view.findViewById(R.id.source_image)).getDrawable()); Bundle arguments = new Bundle(); arguments.putInt("position", position); arguments.putString("type", dataItem.getType()); arguments.putString("title", dataItem.getTitle()); arguments.putString("data", dataItem.getData()); arguments.putInt("num", dataItem.getNum()); arguments.putBoolean("use", dataItem.isUse()); arguments.putBoolean("preview", dataItem.isPreview()); String imageFileName = dataItem.getImageFile().getAbsolutePath(); if (imageFileName != null && imageFileName.length() > 0) { arguments.putString("image", imageFileName); } else { arguments.putString("image", ""); } arguments.putBoolean("use_time", dataItem.isUseTime()); arguments.putString("time", dataItem.getTime()); sourceInfoFragment.setArguments(arguments); final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container); final CardView sourceCard = (CardView) view.findViewById(R.id.source_card); final View imageOverlay = view.findViewById(R.id.source_image_overlay); final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title); final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container); final float cardStartShadow = sourceCard.getPaddingLeft(); final float viewStartHeight = sourceContainer.getHeight(); final float viewStartY = view.getY(); final int viewStartPadding = view.getPaddingLeft(); final float textStartX = sourceTitle.getX(); final float textStartY = sourceTitle.getY(); final float textTranslationY = sourceTitle.getHeight(); /*+ TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());*/ Animation animation = new Animation() { private boolean needsFragment = true; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (needsFragment && interpolatedTime >= 1) { needsFragment = false; getFragmentManager().beginTransaction() .add(R.id.content_frame, sourceInfoFragment, "source_info_fragment") .addToBackStack(null).setTransition(FragmentTransaction.TRANSIT_NONE).commit(); } int newPadding = Math.round(viewStartPadding * (1 - interpolatedTime)); int newShadowPadding = (int) (cardStartShadow * (1.0f - interpolatedTime)); sourceCard.setShadowPadding(newShadowPadding, 0, newShadowPadding, 0); ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).topMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).bottomMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).leftMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).rightMargin = newShadowPadding; view.setPadding(newPadding, 0, newPadding, 0); view.setY(viewStartY - interpolatedTime * viewStartY); ViewGroup.LayoutParams params = sourceContainer.getLayoutParams(); params.height = (int) (viewStartHeight + (screenHeight - viewStartHeight) * interpolatedTime); sourceContainer.setLayoutParams(params); sourceTitle.setY(textStartY + interpolatedTime * textTranslationY); sourceTitle.setX(textStartX + viewStartPadding - newPadding); deleteButton.setAlpha(1.0f - interpolatedTime); viewButton.setAlpha(1.0f - interpolatedTime); editButton.setAlpha(1.0f - interpolatedTime); sourceExpandContainer.setAlpha(1.0f - interpolatedTime); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } @Override public void onAnimationRepeat(Animation animation) { } }); ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getDialogColor(appContext), getResources().getColor(AppSettings.getBackgroundColorResource())); cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue()); } }); ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), sourceTitle.getCurrentTextColor(), getResources().getColor(R.color.BLUE_OPAQUE)); titleColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceTitle.setTextColor((Integer) animation.getAnimatedValue()); } }); ValueAnimator titleShadowAlphaAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getColorFilterInt(appContext), getResources().getColor(android.R.color.transparent)); titleShadowAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceTitle.setShadowLayer(4, 0, 0, (Integer) animation.getAnimatedValue()); } }); ValueAnimator imageOverlayAlphaAnimation = ValueAnimator.ofFloat(imageOverlay.getAlpha(), 0f); imageOverlayAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { imageOverlay.setAlpha((Float) animation.getAnimatedValue()); } }); int transitionTime = INFO_ANIMATION_TIME; DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f); animation.setDuration(transitionTime); cardColorAnimation.setDuration(transitionTime); titleColorAnimation.setDuration(transitionTime); titleShadowAlphaAnimation.setDuration(transitionTime); animation.setInterpolator(decelerateInterpolator); cardColorAnimation.setInterpolator(decelerateInterpolator); titleColorAnimation.setInterpolator(decelerateInterpolator); titleShadowAlphaAnimation.setInterpolator(decelerateInterpolator); if (imageOverlay.getAlpha() > 0) { imageOverlayAlphaAnimation.start(); } handler.postDelayed(new Runnable() { @Override public void run() { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } }, (long) (transitionTime * 1.1f)); needsListReset = true; view.startAnimation(animation); cardColorAnimation.start(); titleColorAnimation.start(); titleShadowAlphaAnimation.start(); }