List of usage examples for android.widget TextView setTypeface
public void setTypeface(@Nullable Typeface tf)
From source file:com.gh4a.activities.IssueCreateActivity.java
private void handleLabelClick(TextView tvLabel, Label label, boolean select) { Gh4Application app = Gh4Application.get(this); if (!select) { mSelectedLabels.remove(label);//from w w w .java 2s .c o m tvLabel.setTypeface(app.condensed); tvLabel.setBackgroundColor(0); tvLabel.setTextColor(getResources() .getColor(Gh4Application.THEME != R.style.LightTheme ? R.color.abs__primary_text_holo_dark : R.color.abs__primary_text_holo_light)); } else { int color = Color.parseColor("#" + label.getColor()); mSelectedLabels.add(label); tvLabel.setTypeface(app.boldCondensed); tvLabel.setBackgroundColor(color); tvLabel.setTextColor(UiUtils.textColorForBackground(this, color)); } }
From source file:com.example.drugsformarinemammals.Combined_Search.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.combined_search); helper = new Handler_Sqlite(this); userEntryAnatomicalTarget = ""; userEntryTherapeuticTarget = ""; userEntryAnimalTarget = ""; TextView title = (TextView) findViewById(R.id.CombinedSearch); title.setTypeface(Typeface.SANS_SERIF); Button go = (Button) findViewById(R.id.goButton); go.setTypeface(Typeface.SANS_SERIF); go.setOnClickListener(new OnClickListener() { @Override/*w w w .jav a 2 s .c o m*/ public void onClick(View v) { userEntryTherapeuticTarget = actv.getText().toString(); search(); } }); Spinner spinnerAnatomicalTarget = (Spinner) findViewById(R.id.SpinAnatomicalTarget); SpinnerAdapter adapterAnatomicalTarget = new SpinnerAdapter(this, R.layout.item_spinner, Arrays.asList(getResources().getStringArray(R.array.AnatomicalTarget))); adapterAnatomicalTarget.setDropDownViewResource(R.layout.spinner_dropdown_item); spinnerAnatomicalTarget.setAdapter(adapterAnatomicalTarget); spinnerAnatomicalTarget.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryAnatomicalTarget = parent.getSelectedItem().toString(); } public void onNothingSelected(AdapterView<?> arg0) { } }); String[] urls = { "http://formmulary.tk/Android/getTherapeuticGroups.php" }; new GetTherapeuticGroups(this).execute(urls); Spinner spinnerAnimals = (Spinner) findViewById(R.id.SpinAnimals); SpinnerAdapter adapterAnimals = new SpinnerAdapter(this, R.layout.item_spinner, Arrays.asList(getResources().getStringArray(R.array.Animals))); adapterAnimals.setDropDownViewResource(R.layout.spinner_dropdown_item); spinnerAnimals.setAdapter(adapterAnimals); spinnerAnimals.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryAnimalTarget = parent.getSelectedItem().toString(); } public void onNothingSelected(AdapterView<?> arg0) { } }); }
From source file:com.aniruddhc.acemusic.player.BlacklistManagerActivity.BlacklistManagerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mApp = (Common) getActivity().getApplicationContext(); View rootView = (ViewGroup) inflater.inflate(R.layout.fragment_blacklist_manager, container, false); mContext = getActivity().getApplicationContext(); ImageView blacklistImage = (ImageView) rootView.findViewById(R.id.blacklist_image); blacklistImage.setImageResource(UIElementsHelper.getIcon(mContext, "manage_blacklists")); MANAGER_TYPE = getArguments().getString("MANAGER_TYPE"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Get a cursor with a list of blacklisted elements. if (MANAGER_TYPE.equals("ARTISTS")) { builder.setTitle(R.string.blacklisted_artists); cursor = mApp.getDBAccessHelper().getBlacklistedArtists(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish();//from w ww. j a v a2 s .c o m } else { //Load the cursor data into temporary ArrayLists. for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST))); } } } else if (MANAGER_TYPE.equals("ALBUMS")) { builder.setTitle(R.string.blacklisted_albums); cursor = mApp.getDBAccessHelper().getBlacklistedAlbums(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish(); } else { //Load the cursor data into temporary ArrayLists. for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM))); artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST))); } } } else if (MANAGER_TYPE.equals("SONGS")) { builder.setTitle(R.string.blacklisted_songs); cursor = mApp.getDBAccessHelper().getAllBlacklistedSongs(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount() == 0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish(); } else { //Load the cursor data into temporary ArrayLists. for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_TITLE))); artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST))); filePathList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH))); songIdsList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ID))); } } } else if (MANAGER_TYPE.equals("PLAYLISTS")) { /*builder.setTitle(R.string.blacklisted_playlists); DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity()); cursor = playlistsDBHelper.getAllBlacklistedPlaylists(); //Finish the activity if there are no blacklisted elements. if (cursor.getCount()==0) { Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show(); getActivity().finish(); } else { //Load the cursor data into temporary ArrayLists. for (int i=0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_NAME))); artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.NUMBER_OF_SONGS))); filePathList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_FILE_PATH))); } }*/ } else { Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_LONG).show(); getActivity().finish(); } TextView blacklistManagerInfoText = (TextView) rootView.findViewById(R.id.blacklist_manager_info_text); DragSortListView blacklistManagerListView = (DragSortListView) rootView .findViewById(R.id.blacklist_manager_list); blacklistManagerListView.setRemoveListener(onRemove); blacklistManagerInfoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); blacklistManagerInfoText.setPaintFlags( blacklistManagerInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); blacklistManagerListView.setFastScrollEnabled(true); adapter = new BlacklistedElementsAdapter(getActivity(), elementNameList, artistNameList, MANAGER_TYPE); blacklistManagerListView.setAdapter(adapter); return rootView; }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** Apply the typeface to the given viewId, and enable subpixel rendering. */ public BaseAdapterHelper setTypeface(int viewId, Typeface typeface) { TextView view = retrieveView(viewId); view.setTypeface(typeface); view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); return this; }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Apply the typeface to all the given viewIds, and enable subpixel * rendering./*from www.j a v a 2 s .c o m*/ */ public BaseAdapterHelper setTypeface(Typeface typeface, int... viewIds) { for (int viewId : viewIds) { TextView view = retrieveView(viewId); view.setTypeface(typeface); view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } return this; }
From source file:com.dotcom.jamaat.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 www .ja v a2 s. c o m */ protected TextView createDefaultTabView(Context context) { // TextView textView = new TextView(context); // textView.setGravity(Gravity.CENTER); // textView.setTextSize(context.getResources().getDimension(R.dimen.dimen_9_sp)); // textView.setTypeface(Typeface.DEFAULT); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Regular.ttf"); textView.setTypeface(font); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); 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(10, padding, 10, padding); return textView; /*// WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); //*/ // 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(0,20,0,20); // // return textView; }
From source file:com.agenmate.lollipop.addedit.AddEditFragment.java
private void formatText(TextView textView, String string) { if (string != null) { textView.setText(MarkupUtils.fromHtml(string)); }// w w w . jav a2s .c o m textView.setTextColor(Color.BLACK); textView.setTypeface(FontUtils.get(getActivity(), "Dudu")); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); }
From source file:cn.scujcc.bug.bitcoinplatformandroid.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 ww w .j av 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.DEFAULT_BOLD); textView.setWidth(screenX); 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.gh4a.IssueCreateActivity.java
@Override public void onCreate(Bundle savedInstanceState) { setTheme(Gh4Application.THEME);/*w ww .j a v a 2 s.c o m*/ super.onCreate(savedInstanceState); mSelectedLabels = new ArrayList<Label>(); Bundle data = getIntent().getExtras(); mRepoOwner = data.getString(Constants.Repository.REPO_OWNER); mRepoName = data.getString(Constants.Repository.REPO_NAME); mIssueNumber = data.getInt(Constants.Issue.ISSUE_NUMBER); if (mIssueNumber != 0) { mEditMode = true; } if (!isOnline()) { setErrorView(); return; } if (!isAuthorized()) { Intent intent = new Intent().setClass(this, Github4AndroidActivity.class); startActivity(intent); finish(); } setContentView(R.layout.issue_create); mActionBar = getSupportActionBar(); mActionBar.setTitle(mEditMode ? getResources().getString(R.string.issue_edit) + " #" + mIssueNumber : getResources().getString(R.string.issue_create)); mActionBar.setSubtitle(mRepoOwner + "/" + mRepoName); mActionBar.setDisplayHomeAsUpEnabled(true); mEtTitle = (EditText) findViewById(R.id.et_title); mEtDesc = (EditText) findViewById(R.id.et_desc); mLinearLayoutLabels = (LinearLayout) findViewById(R.id.ll_labels); mTvSelectedMilestone = (EditText) findViewById(R.id.et_milestone); mTvSelectedAssignee = (EditText) findViewById(R.id.et_assignee); TextView tvIssueLabelAdd = (TextView) findViewById(R.id.tv_issue_label_add); tvIssueLabelAdd.setTypeface(getApplicationContext().boldCondensed); tvIssueLabelAdd.setTextColor(Color.parseColor("#0099cc")); getSupportLoaderManager().initLoader(0, null, this); getSupportLoaderManager().initLoader(1, null, this); getSupportLoaderManager().initLoader(2, null, this); getSupportLoaderManager().initLoader(4, null, this); LinearLayout ll = (LinearLayout) findViewById(R.id.for_collaborator); ll.setVisibility(View.GONE); if (mEditMode) { showLoading(); getSupportLoaderManager().initLoader(3, null, this); getSupportLoaderManager().getLoader(3).forceLoad(); } else { hideLoading(); getSupportLoaderManager().getLoader(4).forceLoad(); } }
From source file:com.gh4a.IssueCreateActivity.java
public void fillLabels() { final Typeface boldCondensed = getApplicationContext().boldCondensed; final Typeface condensed = getApplicationContext().condensed; for (final Label label : mAllLabel) { final View rowView = getLayoutInflater().inflate(R.layout.row_issue_create_label, null); View viewColor = (View) rowView.findViewById(R.id.view_color); viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor())); //viewColor.setPadding(10, 10, 10, 10); final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title); tvLabel.setTypeface(condensed); tvLabel.setText(label.getName()); tvLabel.setOnClickListener(new OnClickListener() { @Override/*w w w. j ava 2 s . co m*/ public void onClick(View v) { if (mSelectedLabels.contains(label)) { mSelectedLabels.remove(label); tvLabel.setTypeface(condensed); tvLabel.setBackgroundColor(0); if (Gh4Application.THEME == R.style.LightTheme) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } } else { mSelectedLabels.add(label); tvLabel.setTypeface(boldCondensed); tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor())); int r = Color.red(Color.parseColor("#" + label.getColor())); int g = Color.green(Color.parseColor("#" + label.getColor())); int b = Color.blue(Color.parseColor("#" + label.getColor())); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } } } }); if (mEditMode) { if (mSelectedLabels.contains(label)) { tvLabel.setTypeface(boldCondensed); tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor())); int r = Color.red(Color.parseColor("#" + label.getColor())); int g = Color.green(Color.parseColor("#" + label.getColor())); int b = Color.blue(Color.parseColor("#" + label.getColor())); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } } else { tvLabel.setTypeface(condensed); tvLabel.setBackgroundColor(0); if (Gh4Application.THEME == R.style.LightTheme) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } } } mLinearLayoutLabels.addView(rowView); } }