Example usage for android.widget TextView setAlpha

List of usage examples for android.widget TextView setAlpha

Introduction

In this page you can find the example usage for android.widget TextView setAlpha.

Prototype

public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) 

Source Link

Document

Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

Usage

From source file:Main.java

public static void showTapText(TextView view) {
    view.setVisibility(View.VISIBLE);
    view.setAlpha(ANIMATION_IN);
    ViewCompat.animate(view).alphaBy(ANIMATION_OUT).setDuration(ANIMATION_TAP_DURATION);
}

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));
    }// w  ww  .j  a  v a2  s .co  m

    // ?? 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:de.dev.eth0.android.sample.navigationDrawer.view.slidingtab.SlidingTabLayout.java

/**
 * scroll to the selected tab/*from  ww w . j  a v a 2s .c o m*/
 *
 * @param tabIndex
 * @param positionOffset
 */
private void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;
    }

    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;

        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey the offset
            targetScrollX -= mTitleOffset;
        }
        // update textviews of old selected and new (alpha)
        View oldSelected = mTabStrip.getChildAt(mActiveTab);
        if (tabIndex != mActiveTab && TextView.class.isInstance(selectedChild)
                && TextView.class.isInstance(oldSelected)) {
            TextView tv = (TextView) selectedChild;
            TextView old = (TextView) oldSelected;
            tv.setAlpha(1f);
            old.setAlpha(0.5f);
            mActiveTab = tabIndex;
        }
        scrollTo(targetScrollX, 0);
    }
}

From source file:de.dev.eth0.android.sample.navigationDrawer.view.slidingtab.SlidingTabLayout.java

/**
 * Creates the textview for a single entry.
 *
 * @param context/*from   w  ww. ja  v a2s.  c  o m*/
 * @param isActive
 * @return the textview
 */
protected TextView createTabView(Context context, boolean isActive) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(Color.WHITE);
    if (!isActive) {
        textView.setAlpha(0.5f);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.hannesdorfmann.home.HomeActivity.java

private void animateToolbar() {
    // this is gross but toolbar doesn't expose it's children to animate them :(
    View t = toolbar.getChildAt(0);
    if (t != null && t instanceof TextView) {
        TextView title = (TextView) t;

        // fade in and space out the title.  Animating the letterSpacing performs horribly so
        // fake it by setting the desired letterSpacing then animating the scaleX \_()_/
        title.setAlpha(0f);
        title.setScaleX(0.8f);/*from ww w  . ja  v  a 2 s . c  o  m*/

        title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900).setInterpolator(
                AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in));
    }
    View amv = toolbar.getChildAt(1);
    if (amv != null & amv instanceof ActionMenuView) {
        ActionMenuView actions = (ActionMenuView) amv;
        popAnim(actions.getChildAt(0), 500, 200); // filter
        popAnim(actions.getChildAt(1), 700, 200); // overflow
    }
}

From source file:com.android.yijiang.kzx.widget.PagerSlidingTabStrip.java

private void changeToChild(int position) {
    if (tabCount == 0) {
        return;//ww w. jav  a2  s.c  o m
    }

    //      if(position!=mPageIndex){
    //         TextView childTextView=(TextView) tabsContainer.getChildAt(position);
    //         TextView offsetTextView=(TextView) tabsContainer.getChildAt(mPageIndex);
    //         
    ////         childTextView.setTextColor(indicatorColor);
    ////         offsetTextView.setTextColor(tabTextColor);
    //         childTextView.setTextColor(Color.parseColor("#666666"));
    //         childTextView.getPaint().setFakeBoldText(false);
    //         offsetTextView.setTextColor(Color.parseColor("#666666"));
    //         offsetTextView.getPaint().setFakeBoldText(false);
    //      }else{
    //         TextView childTextView=(TextView) tabsContainer.getChildAt(position);
    ////         childTextView.setTextColor(indicatorColor);
    //         childTextView.setTextColor(Color.parseColor("#444444"));
    //         childTextView.getPaint().setFakeBoldText(true);
    //      }
    //      
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            if (position == i) {
                tab.setTextColor(Color.parseColor("#444444"));
                tab.setAlpha(1.0f);
                tab.getPaint().setFakeBoldText(true);
            } else {
                tab.setTextColor(Color.parseColor("#666666"));
                tab.setAlpha(0.7f);
                tab.getPaint().setFakeBoldText(false);
            }

        }
    }

}

From source file:com.android.tv.menu.MenuLayoutManager.java

private void setTempTitleView(TextView dest, TextView src) {
    dest.setVisibility(View.VISIBLE);
    dest.setText(src.getText());//from w ww .  j  a  v a2  s  .  co m
    dest.setTranslationY(0.0f);
    if (src.getVisibility() == View.VISIBLE) {
        dest.setAlpha(src.getAlpha());
        dest.setScaleX(src.getScaleX());
        dest.setScaleY(src.getScaleY());
    } else {
        dest.setAlpha(0.0f);
        dest.setScaleX(1.0f);
        dest.setScaleY(1.0f);
    }
    View parent = (View) src.getParent();
    dest.setLeft(src.getLeft() + parent.getLeft());
    dest.setRight(src.getRight() + parent.getLeft());
    dest.setTop(src.getTop() + parent.getTop());
    dest.setBottom(src.getBottom() + parent.getTop());
}

From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java

private boolean showPickupsInfo(final LocalDate date) {
    final List<PickupInfo> from = DB.pickups().findByFrom(date, true);
    if (!from.isEmpty()) {

        TextView title = ((TextView) bottomSheet.findViewById(R.id.bottom_sheet_title));

        LayoutInflater i = getLayoutInflater();
        LinearLayout list = (LinearLayout) findViewById(R.id.pickup_list);
        list.removeAllViews();/*from   ww  w  . j ava 2 s . c o  m*/
        for (final PickupInfo p : from) {

            Medicine m = DB.medicines().findById(p.medicine().getId());
            Patient pat = DB.patients().findById(m.patient().id());

            if (selectedPatientIdx == 0 || pat.id() == selectedPatientId) {

                View v = i.inflate(R.layout.calendar_pickup_list_item, null);
                TextView tv1 = ((TextView) v.findViewById(R.id.textView));
                TextView tv2 = ((TextView) v.findViewById(R.id.textView2));
                ImageView avatar = ((ImageView) v.findViewById(R.id.avatar));
                String interval = getResources().getString(R.string.pickup_interval, p.to().toString(df));

                if (p.taken()) {
                    interval += " ";
                    tv1.setAlpha(0.5f);
                } else {
                    tv1.setAlpha(1f);
                    tv2.setAlpha(1f);
                }

                tv1.setText(p.medicine().name());
                tv2.setText(interval);
                avatar.setImageResource(AvatarMgr.res(pat.avatar()));

                tv1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        p.taken(!p.taken());
                        DB.pickups().save(p);
                        showPickupsInfo(date);
                    }
                });
                list.addView(v);
            }
        }
        nestedScrollView.scrollBy(0, bottomSheet.getHeight());
        showBottomSheet();
        int total = list.getChildCount();
        title.setText(
                total + " " + getResources().getString(R.string.title_pickups_bottom_sheet, date.toString(df)));
        appBarLayout.setExpanded(false, true);
        return true;
    }
    return false;
}

From source file:io.plaidapp.ui.HomeActivity.java

private void animateToolbar() {
    // this is gross but toolbar doesn't expose it's children to animate them :(
    View t = toolbar.getChildAt(0);
    if (t != null && t instanceof TextView) {
        TextView title = (TextView) t;

        // fade in and space out the title.  Animating the letterSpacing performs horribly so
        // fake it by setting the desired letterSpacing then animating the scaleX \_()_/
        title.setAlpha(0f);
        title.setScaleX(0.8f);/*w  w w.  ja v  a 2 s  .  com*/

        title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900)
                .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this));
    }
}

From source file:com.eccyan.widget.SpinningTabStrip.java

private void notSelected(View tab) {
    TextView title = (TextView) tab.findViewById(R.id.tab_title);
    if (title != null) {
        title.setTypeface(tabTypeface, tabTypefaceStyle);
        title.setAlpha(tabTextAlpha);
    }//from ww  w . j  ava2  s  .  c  o m
}