List of usage examples for android.graphics Typeface MONOSPACE
Typeface MONOSPACE
To view the source code for android.graphics Typeface MONOSPACE.
Click Source Link
From source file:com.pishtaz.mylastnews.utils.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 w w w . j a va 2s . c om*/ */ 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.MONOSPACE); 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(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); int padding2 = (int) (TAB_VIEW_PADDING_DIPS2 * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding2, padding, padding2); return textView; }
From source file:com.demo.panguso.demo160714.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)}./*w ww.j a v a 2s . c o 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.MONOSPACE); 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(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.hongbaogou.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)}./*from w w w .j av a 2s. c o m*/ * <p/> * tabview */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 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.MONOSPACE); 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(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:color.kidpaint.com.kidpaintcolor.tools.implementation.TextTool.java
public void updateTypeface() { int style;/* www . ja va 2s . co m*/ if (mItalic) { style = Typeface.ITALIC; } else { style = Typeface.NORMAL; } if (mFont.equals("Sans Serif")) { mTextPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, style)); } else if (mFont.equals("Serif")) { mTextPaint.setTypeface(Typeface.create(Typeface.SERIF, style)); } else if (mFont.equals("Monospace")) { mTextPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, style)); } if (Build.VERSION.SDK_INT < 21) { mTextPaint.setTextSkewX(0.0f); if (mFont.equals("Monospace")) { mTextPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL)); if (style == Typeface.ITALIC) { mTextPaint.setTextSkewX(-0.25f); } } } }
From source file:com.slushpupie.deskclock.DeskClock.java
/** Called when the activity is first created. */ @Override// w w w . jav a2 s.c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); layout = (LinearLayout) findViewById(R.id.layout); display = (DisplayView) findViewById(R.id.display); registerForContextMenu(display); display.setOnTouchListener(this); display.setOnClickListener(this); fonts = new Typeface[17]; fonts[0] = Typeface.DEFAULT_BOLD; fonts[1] = Typeface.SANS_SERIF; fonts[2] = Typeface.SERIF; fonts[3] = Typeface.MONOSPACE; fonts[4] = Typeface.createFromAsset(getAssets(), "fonts/Abduction2000.ttf"); fonts[5] = Typeface.createFromAsset(getAssets(), "fonts/DSPoint.ttf"); fonts[6] = Typeface.createFromAsset(getAssets(), "fonts/DSTerminal.ttf"); fonts[7] = Typeface.createFromAsset(getAssets(), "fonts/DT104.ttf"); fonts[8] = Typeface.createFromAsset(getAssets(), "fonts/Delusion.ttf"); fonts[9] = Typeface.createFromAsset(getAssets(), "fonts/jd_scarabeo.ttf"); fonts[10] = Typeface.createFromAsset(getAssets(), "fonts/stencilla.ttf"); fonts[11] = Typeface.createFromAsset(getAssets(), "fonts/Digital2.ttf"); fonts[12] = Typeface.createFromAsset(getAssets(), "fonts/DigitaldreamFat.ttf"); fonts[13] = Typeface.createFromAsset(getAssets(), "fonts/DisplayDots.ttf"); fonts[14] = Typeface.createFromAsset(getAssets(), "fonts/digi.otf"); fonts[15] = Typeface.createFromAsset(getAssets(), "fonts/GentiumBinary.ttf"); fonts[16] = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf"); loadPrefs(); if (lastChangelog == null || !lastChangelog.equals(getString(R.string.app_version))) { DialogFragment df = ChangelogDialog.newInstance(); df.show(getSupportFragmentManager(), "dialog"); } configureDisplay(); resizeClock(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); }
From source file:org.yaaic.activity.ConversationActivity.java
/** * On create// w w w . ja va2 s. c o m */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); serverId = getIntent().getExtras().getInt("serverId"); server = Yaaic.getInstance().getServerById(serverId); Settings settings = new Settings(this); // Finish activity if server does not exist anymore - See #55 if (server == null) { this.finish(); } ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setTitle(server.getTitle()); setContentView(R.layout.conversations); boolean isLandscape = (getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); EditText input = (EditText) findViewById(R.id.input); input.setOnKeyListener(inputKeyListener); pager = (ViewPager) findViewById(R.id.pager); pagerAdapter = new ConversationPagerAdapter(this, server); pager.setAdapter(pagerAdapter); final float density = getResources().getDisplayMetrics().density; indicator = (ConversationIndicator) findViewById(R.id.titleIndicator); indicator.setServer(server); indicator.setTypeface(Typeface.MONOSPACE); indicator.setViewPager(pager); indicator.setFooterColor(0xFF31B6E7); indicator.setFooterLineHeight(1 * density); indicator.setFooterIndicatorHeight(3 * density); indicator.setFooterIndicatorStyle(IndicatorStyle.Underline); indicator.setSelectedColor(0xFFFFFFFF); indicator.setSelectedBold(true); indicator.setBackgroundColor(0xFF181818); historySize = settings.getHistorySize(); if (server.getStatus() == Status.PRE_CONNECTING) { server.clearConversations(); pagerAdapter.clearConversations(); server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize); } float fontSize = settings.getFontSize(); indicator.setTextSize(fontSize * density); input.setTextSize(settings.getFontSize()); input.setTypeface(Typeface.MONOSPACE); // Optimization : cache field lookups Collection<Conversation> mConversations = server.getConversations(); for (Conversation conversation : mConversations) { // Only scroll to new conversation if it was selected before if (conversation.getStatus() == Conversation.STATUS_SELECTED) { onNewConversation(conversation.getName()); } else { createNewConversation(conversation.getName()); } } int setInputTypeFlags = 0; setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; if (settings.autoCapSentences()) { setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } if (isLandscape && settings.imeExtract()) { setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE; } if (!settings.imeExtract()) { input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); } input.setInputType(input.getInputType() | setInputTypeFlags); // Create a new scrollback history scrollback = new Scrollback(); }
From source file:github.bewantbe.audio_analyzer_for_android.AnalyzeActivity.java
@SuppressWarnings("deprecation") private void setTextViewFontSize() { TextView tv = (TextView) findViewById(R.id.textview_cur); // At this point tv.getWidth(), tv.getLineCount() will return 0 Paint mTestPaint = new Paint(); mTestPaint.setTextSize(tv.getTextSize()); mTestPaint.setTypeface(Typeface.MONOSPACE); final String text = getString(R.string.textview_peak_text); Display display = getWindowManager().getDefaultDisplay(); // pixels left float px = display.getWidth() - getResources().getDimension(R.dimen.textview_RMS_layout_width) - 5; float fs = tv.getTextSize(); // size in pixel while (mTestPaint.measureText(text) > px && fs > 5) { fs -= 0.5;//from ww w.ja v a 2s . co m mTestPaint.setTextSize(fs); } ((TextView) findViewById(R.id.textview_cur)).setTextSize(fs / DPRatio); ((TextView) findViewById(R.id.textview_peak)).setTextSize(fs / DPRatio); }
From source file:com.google.corp.productivity.specialprojects.android.samples.fft.AnalyzeActivity.java
@SuppressWarnings("deprecation") private void setTextViewFontSize() { TextView tv = (TextView) findViewById(R.id.textview_cur); // At this point tv.getWidth(), tv.getLineCount() will return 0 Paint mTestPaint = new Paint(); mTestPaint.setTextSize(tv.getTextSize()); mTestPaint.setTypeface(Typeface.MONOSPACE); final String text = "Peak:XXXXX.XHz(AX#+XX) -XXX.XdB"; Display display = getWindowManager().getDefaultDisplay(); // pixels left float px = display.getWidth() - getResources().getDimension(R.dimen.textview_RMS_layout_width) - 5; float fs = tv.getTextSize(); // size in pixel while (mTestPaint.measureText(text) > px && fs > 5) { fs -= 0.5;//w w w . j a v a 2 s . co m mTestPaint.setTextSize(fs); } ((TextView) findViewById(R.id.textview_cur)).setTextSize(fs / DPRatio); ((TextView) findViewById(R.id.textview_peak)).setTextSize(fs / DPRatio); }
From source file:ir.occc.android.irc.activity.ConversationActivity.java
/** * On create/*from w ww . j a v a 2s . c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); serverId = getIntent().getExtras().getInt("serverId"); server = Yaaic.getInstance().getServerById(serverId); Settings settings = new Settings(this); // Finish activity if server does not exist anymore - See #55 if (server == null) { this.finish(); } ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setTitle(server.getTitle()); setContentView(R.layout.irc_conversations); boolean isLandscape = (getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); EditText input = (EditText) findViewById(R.id.input); input.setOnKeyListener(inputKeyListener); pager = (ViewPager) findViewById(R.id.pager); pagerAdapter = new ConversationPagerAdapter(this, server); pager.setAdapter(pagerAdapter); final float density = getResources().getDisplayMetrics().density; indicator = (ConversationIndicator) findViewById(R.id.titleIndicator); indicator.setServer(server); indicator.setTypeface(Typeface.MONOSPACE); indicator.setViewPager(pager); indicator.setFooterColor(0xFF31B6E7); indicator.setFooterLineHeight(1 * density); indicator.setFooterIndicatorHeight(3 * density); indicator.setFooterIndicatorStyle(IndicatorStyle.Underline); indicator.setSelectedColor(0xFFFFFFFF); indicator.setSelectedBold(true); indicator.setBackgroundColor(0xFF181818); historySize = settings.getHistorySize(); if (server.getStatus() == Status.PRE_CONNECTING) { server.clearConversations(); pagerAdapter.clearConversations(); server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize); } float fontSize = settings.getFontSize(); indicator.setTextSize(fontSize * density); input.setTextSize(settings.getFontSize()); input.setTypeface(Typeface.MONOSPACE); // Optimization : cache field lookups Collection<Conversation> mConversations = server.getConversations(); for (Conversation conversation : mConversations) { // Only scroll to new conversation if it was selected before if (conversation.getStatus() == Conversation.STATUS_SELECTED) { onNewConversation(conversation.getName()); } else { createNewConversation(conversation.getName()); } } int setInputTypeFlags = 0; setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; if (settings.autoCapSentences()) { setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } if (isLandscape && settings.imeExtract()) { setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE; } if (!settings.imeExtract()) { input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); } input.setInputType(input.getInputType() | setInputTypeFlags); // Create a new scrollback history scrollback = new Scrollback(); }
From source file:com.jbirdvegas.mgerrit.DiffViewer.java
private void setTextView(String result) { Pattern pattern = Pattern.compile("\\Qdiff --git \\E"); String[] filesChanged = pattern.split(result); StringBuilder builder = new StringBuilder(0); for (String change : filesChanged) { String concat;//from www . j a v a 2s. co m int index = change.lastIndexOf(mFilePath); if (index < 0) continue; concat = change.substring(2, index).trim().split(" ", 2)[0]; if (concat.equals(mFilePath)) { change.replaceAll("\n", mLineSplit); builder.append(change); } } if (builder.length() == 0) { builder.append("Diff not found!"); } else { // reset text size to default mDiffTextView.setTextAppearance(this, android.R.style.TextAppearance_DeviceDefault_Small); mDiffTextView.setTypeface(Typeface.MONOSPACE); } // rebuild text; required to respect the \n mDiffTextView.setDiffText(builder.toString()); }