List of usage examples for android.graphics Typeface createFromAsset
public static Typeface createFromAsset(AssetManager mgr, String path)
From source file:com.ksharkapps.musicnow.ui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}// ww w. j a va 2 s . com */ @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (SettingsActivity.getTranslucentMode(this) && Utils.hasKitKat()) { setTheme(R.style.Apollo_Theme_Dark_Translucent); setTranslucentStatus(true); } // Set up the action bar actionBar = getSupportActionBar(); actionBar.setTitle(R.string.now_playing); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayUseLogoEnabled(false); // Sets fonts for all Typeface font = Typeface.createFromAsset(getAssets(), "RobotoThin.ttf"); ViewGroup root = (ViewGroup) findViewById(R.id.player_bg); // setFont(root, font); // Fade it in overridePendingTransition(R.anim.swipeup_in, R.anim.swipeup_out); // Control the media volume setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(this, this); // Initialize the image fetcher/cache mImageFetcher = ApolloUtils.getImageFetcher(this); // Initialize the handler used to update the current time mTimeHandler = new TimeHandler(this); // Initialize the broadcast receiver mPlaybackStatus = new PlaybackStatus(this); // Theme the action bar final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // Set the layout setContentView(R.layout.activity_player_base); // Cache all the items initPlaybackControls(); }
From source file:com.lfant.tabdemo.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* ww w. j a v a 2 s . c om*/ TextView tabTitleView = null; 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()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/Lucida-Grande-Regular.ttf"); tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); tabTitleView.setTextSize(14); } }
From source file:com.example.ridemedriver.LoginActivity.java
@SuppressLint("NewApi") @Override/*from w w w.j a v a2s . c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); getActionBar().hide(); Typeface face = Typeface.createFromAsset(getAssets(), "fonts/hjt.TTF"); title = (TextView) findViewById(R.id.login_title); title.setTypeface(face); create = (Button) findViewById(R.id.login_bt_create); create.setTypeface(face); create.setOnClickListener(clickListener); telephone_text = (TextView) findViewById(R.id.login_telephone_text); telephone_text.setTypeface(face); telephone_edit = (EditText) findViewById(R.id.login_telephone_edit); telephone_edit.setTypeface(face); password_text = (TextView) findViewById(R.id.login_password_text); password_text.setTypeface(face); password_edit = (EditText) findViewById(R.id.login_password_edit); password_edit.setTypeface(face); forget = (Button) findViewById(R.id.login_forget); forget.setTypeface(face); forget.setOnClickListener(clickListener); login = (Button) findViewById(R.id.login_login); login.setTypeface(face); login.setOnClickListener(clickListener); }
From source file:me.zhang.bingo.Utility.java
public static void applyCustomFont(Context context, TextView targetView) { Typeface font = Typeface.createFromAsset(context.getAssets(), "IndieFlower.ttf"); targetView.setTypeface(font);//from w w w .ja va 2 s . c o m }
From source file:info.tellmetime.TellmetimeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tellmetime); mDensity = getResources().getDisplayMetrics().density; mScreenWidth = getResources().getDisplayMetrics().widthPixels; mScreenHeight = getResources().getDisplayMetrics().heightPixels; mShorterEdge = Math.min(mScreenWidth, mScreenHeight); mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); mBacklightLight = getResources().getColor(R.color.backlight_light); mBacklightDark = getResources().getColor(R.color.backlight_dark); // Restore background and highlight colors from saved values or set defaults. mSettings = getSharedPreferences("PREFS", Context.MODE_PRIVATE); mHighlightColor = mSettings.getInt(HIGHLIGHT, Color.WHITE); mBacklightColor = mSettings.getInt(BACKLIGHT, mBacklightLight); mBackgroundColor = mSettings.getInt(BACKGROUND, getResources().getColor(R.color.background)); mBackgroundMode = mSettings.getInt(BACKGROUND_MODE, MODE_BACKGROUND_SOLID); mHighlightPosition = mSettings.getFloat(POSITION, 0.0f); mMinutesSize = mSettings.getInt(MINUTES_SIZE, 36); isNightMode = mSettings.getBoolean(NIGHTMODE, false); // Dim the navigation bar. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) getWindow().getDecorView().setSystemUiVisibility(isNightMode ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0); mSurface = (RelativeLayout) findViewById(R.id.surface); mSurface.setBackgroundColor(mBackgroundColor); resizeClock();/*from w w w.ja v a2s . c o m*/ Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); // Set typeface of all items in the clock to Roboto and dim each one and drop shadow on them. final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); tv.setTypeface(mTypefaceBold); tv.setTextColor(mBacklightColor); tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTypeface(mTypefaceBold); m.setTextColor(mBacklightColor); m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } // Set Roboto font on TextView where it isn't default. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { Typeface mTypefaceItalic = Typeface.createFromAsset(getAssets(), "Roboto-CondensedItalic.ttf"); ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.info_background)).setTypeface(mTypefaceItalic); ((TextView) findViewById(R.id.info_image)).setTypeface(mTypefaceItalic); ((TextView) findViewById(R.id.labelHighlight)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_light)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_dark)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_highlight)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.labelMinutes)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m1)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m2)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m3)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m4)).setTypeface(mTypefaceBold); } FrameLayout mTouchZone = (FrameLayout) findViewById(R.id.touchZone); mTouchZone.setOnTouchListener(this); mTouchZone.setBackgroundColor( getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent)); mBackgroundImage = (ImageView) findViewById(R.id.background_image); switchBackgroundMode(mBackgroundMode); RelativeLayout mPanel = (RelativeLayout) findViewById(R.id.panel); mPanel.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mHider.delayedHide(4000); return true; } }); mHider = new PanelHider(mPanel, this); Spinner spinnerBackgroundMode = (Spinner) findViewById(R.id.spinnerBackgroundMode); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.backgrounds_modes, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerBackgroundMode.setAdapter(adapter); spinnerBackgroundMode.setOnItemSelectedListener(this); spinnerBackgroundMode.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mHider.showNoAutoHide(); return false; } }); spinnerBackgroundMode.setSelection(mBackgroundMode); mSeekBarHighlight = (SeekBar) findViewById(R.id.highlightValue); mSeekBarHighlight.setOnSeekBarChangeListener(this); // Draw rainbow gradient on #mSeekBarHighlight and set position. drawRainbow(); if (mBacklightColor == mBacklightLight) ((RadioButton) findViewById(R.id.radio_backlight_light)).setChecked(true); else if (mBacklightColor == mBacklightDark) ((RadioButton) findViewById(R.id.radio_backlight_dark)).setChecked(true); else ((RadioButton) findViewById(R.id.radio_backlight_highlight)).setChecked(true); SeekBar mSeekBarMinutes = (SeekBar) findViewById(R.id.minutesSize); mSeekBarMinutes.setOnSeekBarChangeListener(this); mSeekBarMinutes.setProgress(mMinutesSize); mHider.hideNow(); Color.colorToHSV(mBackgroundColor, mHSV); mHSV[1] = 1.0f; //Trigger initial tick. mClockAlgorithm.tickTock(); // Schedule the clock algorithm to tick every round minute. Calendar time = Calendar.getInstance(); time.set(Calendar.MILLISECOND, 0); time.set(Calendar.SECOND, 0); time.add(Calendar.MINUTE, 1); Timer timer = new Timer(); timer.schedule(mClockTask, time.getTime(), 60 * 1000); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSurface.setAlpha(0.0f); mSurface.animate().alpha(1.0f).setDuration(1500); } // If it is first run, hint to user that panel is available. if (!mSettings.contains(HIGHLIGHT)) showToast(R.string.info_first_run); }
From source file:com.neuron.trafikanten.HelperFunctions.java
public static Typeface getTypeface(Activity activity) { if (mTypeface == null) { mTypeface = Typeface.createFromAsset(activity.getAssets(), "fonts/DejaVuSans.ttf"); }/*from w w w .ja va 2s .c o m*/ return mTypeface; }
From source file:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDayDeparturesFragment.java
@SuppressWarnings("deprecation") @Override/*from w w w .j a va 2 s.c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Typeface tfb = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Bold.ttf"); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_swipe_refresh, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorScheme(17170451, // android.R.color.holo_blue_bright 17170452, // android.R.color.holo_green_light 17170456, // android.R.color.holo_orange_light 17170454); // android.R.color.holo_red_light) mHeaderView = inflater.inflate(R.layout.list_item_departure_times_header, null); TextView departing_title = (TextView) mHeaderView.findViewById(R.id.departing_title); departing_title.setTypeface(tfb); TextView arriving_title = (TextView) mHeaderView.findViewById(R.id.arriving_title); arriving_title.setTypeface(tfb); mEmptyView = root.findViewById(R.id.empty_list_view); return root; }
From source file:app.sunstreak.yourpisd.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);//from ww w .ja v a2 s . c o m } // Find the screen height/width DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); SCREEN_HEIGHT = displaymetrics.heightPixels; SCREEN_WIDTH = displaymetrics.widthPixels; session = ((YPApplication) getApplication()).session; // Create the adapter that will return a fragment for each of the three // primary sections of the app. FragmentManager fm = getSupportFragmentManager(); mSectionsPagerAdapter = new SectionsPagerAdapter(fm); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); /* Deprecated as of 1/13/2015. @Han Li */ // setUpTabs(); setUpNavigationDrawer(); AppRater.app_launched(this); mFragments = new YPMainFragment[NUM_FRAGMENTS]; // Opens Spring semester summary by default. currentSummaryFragment = 1; for (int position = 0; position < NUM_FRAGMENTS; position++) { if (position == SUMMARY_FRAGMENT_POSITION) { mFragments[position] = new PlaceholderFragment(); } // else if (position == ATTENDANCE_FRAGMENT_POSITION) { // mFragments[position] = new AttendanceFragment(); // } else { mFragments[position] = new MainActivityFragment(); Bundle args = new Bundle(); args.putInt(MainActivityFragment.ARG_OBJECT, position); mFragments[position].setArguments(args); } } mViewPager.setAdapter(mSectionsPagerAdapter); // setUpMaterialTabs(); // For parents with multiple students, show the profile cards first. // If we are coming back from ClassSwipeActivity, go to requested // section (should be section #1). if (session.MULTIPLE_STUDENTS) { if (getIntent().hasExtra("mainActivitySection")) mViewPager.setCurrentItem(getIntent().getExtras().getInt("mainActivitySection")); else mViewPager.setCurrentItem(0); } // Otherwise, show the current six weeks grades list. else mViewPager.setCurrentItem(1); isAttendanceLoaded = false; MyTextView.typeface = Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf"); if (DateHelper.isAprilFools()) { setUpTroll(); } }
From source file:org.egov.android.view.SlidingTab.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*w w w.j a v a 2 s.c o m*/ TextView tabTitleView = null; 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()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.white)); tabTitleView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/ROBOTO-REGULAR.TTF"), Typeface.BOLD); tabTitleView.setTextSize(16); } }
From source file:com.dv.Utils.Tools.java
/** * getTypeFace description//from ww w. ja v a2 s .c om * Description: * * @param context * @return */ public static Typeface getTypeFace(Context context) { Typeface typeFace = Typeface.createFromAsset(context.getAssets(), "fonts/STHeiti-Light.ttc"); return typeFace; }