List of usage examples for android.graphics Typeface DEFAULT
Typeface DEFAULT
To view the source code for android.graphics Typeface DEFAULT.
Click Source Link
From source file:im.ene.ribbon.ActionTabView.java
public void setTypeface(final SoftReference<Typeface> typeface) { if (null != typeface) { Typeface tf = typeface.get();/*from w ww . j a va2s .co m*/ if (null != tf) { textPaint.setTypeface(tf); } else { textPaint.setTypeface(Typeface.DEFAULT); } textDirty = true; requestLayout(); } }
From source file:com.stoneapp.ourvlemoodle2.adapters.PostListAdapter.java
@Override public void onBindViewHolder(PostListViewHolder holder, int position) { MoodlePost post = postList.get(position); String subject = post.getSubject(); if (!TextUtils.isEmpty(subject)) holder.getSubjectView().setText(subject); String username = post.getUserfullname(); if (!TextUtils.isEmpty(username)) holder.getUserNameView().setText(username); String message = post.getMessage(); if (!TextUtils.isEmpty(message)) holder.getMessageView().setText(message); //Extracts image from string to show in text view CharSequence format_message = Html.fromHtml(message, new Html.ImageGetter() { @Override//from w w w . j a v a2 s. c o m public Drawable getDrawable(String source) { try { //InputStream is = (InputStream) new URL(source).getContent(); //Drawable d = Drawable.createFromStream(is, "sc name"); //d.setBounds(0,0,50,50); //return d; Drawable drawFromPath; int path = context.getResources().getIdentifier(source, "drawable", context.getPackageName()); drawFromPath = ContextCompat.getDrawable(context, path); drawFromPath.setBounds(0, 0, drawFromPath.getIntrinsicWidth(), drawFromPath.getIntrinsicHeight()); return drawFromPath; } catch (Exception e) { e.printStackTrace(); return null; } } }, null); if (!TextUtils.isEmpty(message)) holder.getMessageView().setText(format_message); int time = post.getModified(); holder.getPostTimeView().setText(TimeUtils.getTime(time)); char firstLetter = username.toUpperCase().charAt(0); ColorGenerator generator = ColorGenerator.MATERIAL; int color2 = generator.getColor(username); TextDrawable drawable2 = TextDrawable.builder().beginConfig().textColor(Color.WHITE) .useFont(Typeface.DEFAULT).toUpperCase().endConfig().buildRound(firstLetter + "", color2); holder.getPostImageView().setImageDrawable(drawable2); }
From source file:com.rks.musicx.base.BaseActivity.java
/** * Font load using Calligraphy/*from w ww .j ava2 s. c o m*/ */ private void fontConfig() { switch (Extras.getInstance().fontConfig()) { case Zero: Helper.getCalligraphy(this, "RobotoLight.ttf"); break; case One: Helper.getCalligraphy(this, "Raleway.ttf"); break; case Two: Helper.getCalligraphy(this, "Knul.otf"); break; case Three: Helper.getCalligraphy(this, "CutiveMono.ttf"); break; case Four: Helper.getCalligraphy(this, "Timber.ttf"); break; case "5": Helper.getCalligraphy(this, "Snippet.ttf"); break; case "6": Helper.getCalligraphy(this, "Trench.ttf"); break; case "7": Helper.getCalligraphy(this, "Monad.otf"); break; case "8": Helper.getCalligraphy(this, "Rex.ttf"); break; case "9": Helper.getCalligraphy(this, "ExodusStriped.otf"); break; case "10": Helper.getCalligraphy(this, "GogiaRegular.otf"); break; case "11": Helper.getCalligraphy(this, "MavenPro.ttf"); break; case "12": Helper.getCalligraphy(this, "Vow.ttf"); break; case "13": Helper.getCalligraphy(this, "Nunito.ttf"); break; case "14": Helper.getCalligraphy(this, "Circled.ttf"); break; case "15": Helper.getCalligraphy(this, "Franks.otf"); break; case "16": Helper.getCalligraphy(this, "Mountain.otf"); break; case "17": Helper.getCalligraphy(this, "Jakarta.ttf"); break; case "18": Helper.getCalligraphy(this, "Abyssopelagic.otf"); break; case "19": Helper.getCalligraphy(this, "Tesla.ttf"); break; case "20": Helper.getCalligraphy(this, Typeface.DEFAULT.toString()); break; } }
From source file:org.starfishrespect.myconsumption.android.ui.SlidingStatFragment.java
protected PieData generatePieData() { ArrayList<Entry> entries1 = new ArrayList<Entry>(); ArrayList<String> xVals = new ArrayList<String>(); xVals.add("PEAK TIME: " + StatUtils.wh2kWh(mStat.getConsumptionDay()) + " " + getString(R.string.textview_stat_kWh)); xVals.add("OFF-PEAK TIME: " + StatUtils.wh2kWh(mStat.getConsumptionNight()) + " " + getString(R.string.textview_stat_kWh)); entries1.add(new Entry((float) StatUtils.wh2kWh(mStat.getConsumptionDay()), 0)); entries1.add(new Entry((float) StatUtils.wh2kWh(mStat.getConsumptionNight()), 1)); PieDataSet ds1 = new PieDataSet(entries1, ""); ds1.setColors(ColorTemplate.VORDIPLOM_COLORS); ds1.setSliceSpace(2f);//from w w w . j a va 2 s . c om ds1.setValueTextColor(Color.BLACK); ds1.setValueTextSize(12f); PieData d = new PieData(xVals, ds1); d.setValueTypeface(Typeface.DEFAULT); return d; }
From source file:com.dreamspace.superman.UI.View.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* ww w. j av a 2 s . c om*/ */ protected View createDefaultTabView(Context context) { View v; if (mIconAdapter == null) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT); textView.setAllCaps(true); textView.setTextColor(getStartColor()); if (fillTheWidth) { textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1)); } else { textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); } ; v = textView; } else { ImageView imgView = new TintImageView(context); imgView.setScaleType(ImageView.ScaleType.FIT_XY); imgView.setLayoutParams(new LinearLayout.LayoutParams(mTabIconSize, mTabIconSize)); v = imgView; } TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); v.setBackgroundResource(outValue.resourceId); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); v.setPadding(padding, padding, padding, padding); return v; }
From source file:io.github.carlorodriguez.alarmon.MediaListView.java
protected void query(Uri contentUri, String nameColumn, String selection, int rowResId, String[] displayColumns, int[] resIDs) { this.nameColumn = nameColumn; final ArrayList<String> queryColumns = new ArrayList<>(displayColumns.length + 1); queryColumns.addAll(Arrays.asList(displayColumns)); // The ID column is required for the SimpleCursorAdapter. Make sure to // add it if it's not already there. if (!queryColumns.contains(BaseColumns._ID)) { queryColumns.add(BaseColumns._ID); }//www .jav a 2 s . com Cursor dbCursor; if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { dbCursor = getContext().getContentResolver().query(contentUri, queryColumns.toArray(new String[queryColumns.size()]), selection, null, sortOrder); } else { dbCursor = new MatrixCursor(queryColumns.toArray(new String[queryColumns.size()])); } if (staticCursor != null) { Cursor[] cursors = new Cursor[] { staticCursor, dbCursor }; cursor = new MergeCursor(cursors); } else { cursor = dbCursor; } manageCursor(cursor); this.contentUri = contentUri; final SimpleCursorAdapter adapter = new SimpleCursorAdapter(getContext(), rowResId, cursor, displayColumns, resIDs, 1); // Use a custom binder to highlight the selected element. adapter.setViewBinder(new ViewBinder() { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (view.getVisibility() == View.VISIBLE && view instanceof TextView) { TextView text = (TextView) view; if (isItemChecked(cursor.getPosition())) { text.setTypeface(Typeface.DEFAULT_BOLD); } else { text.setTypeface(Typeface.DEFAULT); } } // Let the default binder do the real work. return false; } }); setAdapter(adapter); setOnItemClickListener(this); }
From source file:com.app.the.bunker.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from www . j a v a2s .c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); textView.setTypeface(Typeface.DEFAULT); textView.setMaxLines(1); textView.setSingleLine(true); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.example.ariana.slidingtabs.iosched.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* w w w . j a va 2 s .co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(false); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:org.thomasamsler.android.flashcards.fragment.CardSetsFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mActivity = (MainActivity) getActivity(); mDataSource = mActivity.getDataSource(); mMainApplication = (MainApplication) mActivity.getApplication(); mMainApplication.registerAction(this, ACTION_DELETE_CARD_UPDATE_CARD_SET); registerForContextMenu(getListView()); mProgressBar = (ProgressBar) mActivity.findViewById(R.id.progressBar); if (null == mCardSets) { mCardSets = mDataSource.getCardSets(); }//from w w w. j a v a 2 s.c om if (0 == mCardSets.size()) { SharedPreferences sharedPreferences = mActivity.getSharedPreferences(AppConstants.PREFERENCE_NAME, Context.MODE_PRIVATE); boolean showSample = sharedPreferences.getBoolean(AppConstants.PREFERENCE_SHOW_SAMPLE, AppConstants.PREFERENCE_SHOW_SAMPLE_DEFAULT); if (showSample) { createDefaultCardSets(); mCardSets = mDataSource.getCardSets(); } else { Toast.makeText(mMainApplication, R.string.list_no_card_sets_message, Toast.LENGTH_SHORT).show(); } } Collections.sort(mCardSets); mArrayAdapter = new ArrayAdapter<CardSet>(mActivity, android.R.layout.simple_list_item_1, mCardSets) { /* * Overwriting getView method to style the list item font. If it's a remote item * that hasn't been clicked on, we style it bold */ @Override public View getView(int position, View convertView, ViewGroup parent) { TextView textView = (TextView) super.getView(position, convertView, parent); CardSet cardSet = mCardSets.get(position); switch (cardSet.getCardCount()) { case 0: textView.setText(Html.fromHtml( cardSet.getTitle() + "<br /><small><i><font color='#989898'>empty</font></i></small>")); break; case 1: textView.setText(Html.fromHtml(cardSet.getTitle() + "<br /><small><i><font color='#989898'>" + cardSet.getCardCount() + " card</font></i></small>")); break; default: textView.setText(Html.fromHtml(cardSet.getTitle() + "<br /><small><i><font color='#989898'>" + cardSet.getCardCount() + " cards</font></i></small>")); break; } if (mCardSets.get(position).isRemote()) { ((TextView) textView).setTypeface(Typeface.DEFAULT_BOLD); } else { ((TextView) textView).setTypeface(Typeface.DEFAULT); } return textView; } }; setListAdapter(mArrayAdapter); }
From source file:com.tanzakesho.azam.tabs.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//ww w . ja v a 2 s . co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setTextColor(getResources().getColor(R.color.White)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(false); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }