Java Code Examples for android.widget.TextSwitcher#setOutAnimation()
The following examples show how to use
android.widget.TextSwitcher#setOutAnimation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OverMenuLayout.java From OverlayMenu with Apache License 2.0 | 6 votes |
private void initializeTextSwitcher(@NonNull final Context context) { selectedTextView = new TextSwitcher(getContext()); selectedTextView.setFactory(this); selectedTextView.setAnimateFirstView(false); selectedTextView.setBackgroundResource(mSelectedTextBackground); if (mTextSwitcherInAnimation != 0) { selectedTextView.setInAnimation(context, mTextSwitcherInAnimation); } if (mTextSwitcherOutAnimation != 0) { selectedTextView.setOutAnimation(context, mTextSwitcherOutAnimation); } LayoutParams params = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT); params.gravity = Gravity.CENTER; selectedTextView.setLayoutParams(params); selectedTextView.setLayerType(LAYER_TYPE_HARDWARE, null); addView(selectedTextView); }
Example 2
Source File: TextSwitcher1.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.text_switcher_1); mSwitcher = (TextSwitcher) findViewById(R.id.switcher); mSwitcher.setFactory(this); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.fade_out); mSwitcher.setInAnimation(in); mSwitcher.setOutAnimation(out); Button nextButton = (Button) findViewById(R.id.next); nextButton.setOnClickListener(this); updateCounter(); }
Example 3
Source File: MainActivity.java From journaldev with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextSwitcher = (TextSwitcher) findViewById(R.id.textSwitcher); mTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView textView = new TextView(MainActivity.this); textView.setTextSize(18); textView.setGravity(Gravity.CENTER); return textView; } }); mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); mImageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); mImageSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView imageView = new ImageView(MainActivity.this); return imageView; } }); mImageSwitcher.setInAnimation(this, android.R.anim.slide_in_left); mImageSwitcher.setOutAnimation(this, android.R.anim.slide_out_right); onSwitch(null); }
Example 4
Source File: ActivitySettings.java From fingen with Apache License 2.0 | 4 votes |
@SuppressLint("PrivateResource") @Override protected void onCreate(Bundle savedInstanceState) { switch (Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "0"))) { case ActivityMain.THEME_LIGHT : setTheme(R.style.AppThemeLight); break; case ActivityMain.THEME_DARK : setTheme(R.style.AppThemeDark); break; default: setTheme(R.style.AppThemeLight); break; } super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); mReplaceFragmentStrategy = new PreferenceScreenNavigationStrategy.ReplaceFragment(this, R.anim.abc_fade_in, R.anim.abc_fade_out, R.anim.abc_fade_in, R.anim.abc_fade_out); if (savedInstanceState == null) { mSettingsFragment = FragmentSettings.newInstance(null); getSupportFragmentManager().beginTransaction().add(R.id.content, mSettingsFragment, "Settings").commit(); } else { mSettingsFragment = (FragmentSettings) getSupportFragmentManager().findFragmentByTag("Settings"); } getSupportFragmentManager().addOnBackStackChangedListener(this); mToolbar = findViewById(R.id.toolbar); setSupportActionBar(mToolbar); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } // Cross-fading title setup. mTitle = getTitle(); mTitleSwitcher = new TextSwitcher(mToolbar.getContext()); mTitleSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView tv = new AppCompatTextView(mToolbar.getContext()); TextViewCompat.setTextAppearance(tv, R.style.TextAppearance_AppCompat_Widget_ActionBar_Title); return tv; } }); mTitleSwitcher.setCurrentText(mTitle); if (ab != null) { ab.setCustomView(mTitleSwitcher); ab.setDisplayShowCustomEnabled(true); ab.setDisplayShowTitleEnabled(false); } // Add to hierarchy before accessing layout params. // int margin = Util.dpToPxOffset(this, 16); // ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mTitleSwitcher.getLayoutParams(); // lp.leftMargin = margin; // lp.rightMargin = margin; mTitleSwitcher.setInAnimation(this, R.anim.abc_fade_in); mTitleSwitcher.setOutAnimation(this, R.anim.abc_fade_out); android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); }
Example 5
Source File: SettingsActivity.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { ((IslamicLibraryApplication) getApplication()).refreshLocale(this, false); super.onCreate(savedInstanceState); // Enable if you use AppCompat 24.1.x. // Fixes.updateLayoutInflaterFactory(getLayoutInflater()); setContentView(R.layout.activity_settings); mReplaceFragmentStrategy = new PreferenceScreenNavigationStrategy .ReplaceFragment(this, R.anim.abc_fade_in, R.anim.abc_fade_out, R.anim.abc_fade_in, R.anim.abc_fade_out); if (savedInstanceState == null) { mSettingsFragment = SettingsFragment.newInstance(null); getSupportFragmentManager().beginTransaction().add(R.id.content, mSettingsFragment, "Settings").commit(); } else { mSettingsFragment = (SettingsFragment) getSupportFragmentManager().findFragmentByTag("Settings"); } getSupportFragmentManager().addOnBackStackChangedListener(this); mToolbar = findViewById(R.id.toolbar); setSupportActionBar(mToolbar); ActionBar ab = getSupportActionBar(); // Cross-fading title setup. mTitle = getTitle(); mTitleSwitcher = new TextSwitcher(mToolbar.getContext()); mTitleSwitcher.setFactory(() -> { TextView tv = new AppCompatTextView(mToolbar.getContext()); TextViewCompat.setTextAppearance(tv, R.style.TextAppearance_AppCompat_Widget_ActionBar_Title); return tv; }); mTitleSwitcher.setCurrentText(mTitle); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); ab.setCustomView(mTitleSwitcher); ab.setDisplayShowCustomEnabled(true); ab.setDisplayShowTitleEnabled(false); } // Add to hierarchy before accessing layout params. int margin = Util.dpToPxOffset(this, 16); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mTitleSwitcher.getLayoutParams(); lp.leftMargin = margin; lp.rightMargin = margin; mTitleSwitcher.setInAnimation(this, R.anim.abc_fade_in); mTitleSwitcher.setOutAnimation(this, R.anim.abc_fade_out); }
Example 6
Source File: MainActivity.java From android-TextSwitcher with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sample_main); // Get the TextSwitcher view from the layout mSwitcher = (TextSwitcher) findViewById(R.id.switcher); // BEGIN_INCLUDE(setup) // Set the factory used to create TextViews to switch between. mSwitcher.setFactory(mFactory); /* * Set the in and out animations. Using the fade_in/out animations * provided by the framework. */ Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.fade_out); mSwitcher.setInAnimation(in); mSwitcher.setOutAnimation(out); // END_INCLUDE(setup) /* * Setup the 'next' button. The counter is incremented when clicked and * the new value is displayed in the TextSwitcher. The change of text is * automatically animated using the in/out animations set above. */ Button nextButton = (Button) findViewById(R.id.button); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCounter++; // BEGIN_INCLUDE(settext) mSwitcher.setText(String.valueOf(mCounter)); // END_INCLUDE(settext) } }); // Set the initial text without an animation mSwitcher.setCurrentText(String.valueOf(mCounter)); }