List of usage examples for android.graphics Typeface BOLD
int BOLD
To view the source code for android.graphics Typeface BOLD.
Click Source Link
From source file:app.android.datetimepicker.date.SimpleMonthView.java
/** * Sets up the text and style properties for painting. Override this if you * want to use a different paint./*from w ww . jav a 2 s. c o m*/ */ protected void initView() { mMonthTitlePaint = new Paint(); mMonthTitlePaint.setFakeBoldText(true); mMonthTitlePaint.setAntiAlias(true); mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE); mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD)); mMonthTitlePaint.setColor(mDayTextColor); mMonthTitlePaint.setTextAlign(Align.CENTER); mMonthTitlePaint.setStyle(Style.FILL); mMonthTitleBGPaint = new Paint(); mMonthTitleBGPaint.setFakeBoldText(true); mMonthTitleBGPaint.setAntiAlias(true); mMonthTitleBGPaint.setColor(mMonthTitleBGColor); mMonthTitleBGPaint.setTextAlign(Align.CENTER); mMonthTitleBGPaint.setStyle(Style.FILL); mSelectedCirclePaint = new Paint(); mSelectedCirclePaint.setFakeBoldText(true); mSelectedCirclePaint.setAntiAlias(true); mSelectedCirclePaint.setColor(mTodayNumberColor); mSelectedCirclePaint.setTextAlign(Align.CENTER); mSelectedCirclePaint.setStyle(Style.FILL); mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA); mMonthDayLabelPaint = new Paint(); mMonthDayLabelPaint.setAntiAlias(true); mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE); mMonthDayLabelPaint.setColor(mDayTextColor); mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL)); mMonthDayLabelPaint.setStyle(Style.FILL); mMonthDayLabelPaint.setTextAlign(Align.CENTER); mMonthDayLabelPaint.setFakeBoldText(true); mMonthNumPaint = new Paint(); mMonthNumPaint.setAntiAlias(true); mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE); mMonthNumPaint.setStyle(Style.FILL); mMonthNumPaint.setTextAlign(Align.CENTER); mMonthNumPaint.setFakeBoldText(false); }
From source file:com.gruporaido.tasker_library.util.Helper.java
/** * @param drawableId/* w w w. ja v a2 s. c o m*/ * @param text * @param textSize * @param offsetX * @param offsetY * @return */ public Bitmap drawTextOnDrawable(int drawableId, String text, int textSize, int offsetX, int offsetY) { Bitmap bm = BitmapFactory.decodeResource(mContext.getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true); Typeface tf = Typeface.create("Helvetica", Typeface.BOLD); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTypeface(tf); paint.setTextAlign(Paint.Align.CENTER); paint.setTextSize(dpToPx(textSize)); Rect textRect = new Rect(); paint.getTextBounds(text, 0, text.length(), textRect); Canvas canvas = new Canvas(bm); //If the text is bigger than the canvas , reduce the font size if (textRect.width() >= (canvas.getWidth() - 4)) //the padding on either sides is considered as 4, so as to appropriately fit in the text paint.setTextSize(dpToPx(textSize / 2)); //Scaling needs to be used for different dpi's //Calculate the positions int xPos = (canvas.getWidth() / 2) - 2 + dpToPx(offsetX); //-2 is for regulating the x position offset //"- ((paint.descent() + paint.ascent()) / 2)" is the distance from the baseline to the center. int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)) + dpToPx(offsetY); canvas.drawText(text, xPos, yPos, paint); return bm; }
From source file:com.microsoft.rightsmanagement.ui.widget.UserPolicyViewerFragment.java
/** * Updates the policy viewer according to the ownership *//* w w w. j a va 2s . c o m*/ private void updateViewAccordingToOwnership() { UserPolicyModel userPolicyModel = mUserPolicyDataProvider.getUserPolicyModel(); // if this is not owner just show the rights with no header if (userPolicyModel.isIssuedToOwner()) { Logger.d(TAG, "user is the owner of user policy"); mUpperTitleTextView.setText(getString(R.string.policy_viewer_owner_content)); mOwnerNameTextView.setVisibility(View.GONE); setPolicyEditingButtonViewState(mUserPolicyDataProvider.isUserPolicyEditingEnabled()); } else { Logger.d(TAG, "user is not the owner of user policy"); //ignore input of allowing edit enabled and hide policy edit button setPolicyEditingButtonViewState(false); mUpperTitleTextView.setText(R.string.policy_viewer_non_owner_content); SpannableStringBuilder sb = new SpannableStringBuilder(); String grantedBy = getString(R.string.granted_by_string); sb.append(grantedBy); sb.append(" "); sb.append(userPolicyModel.getOwner()); sb.setSpan(new StyleSpan(Typeface.BOLD), grantedBy.length(), sb.length(), 0); mOwnerNameTextView.setText(sb); drawRights(); } }
From source file:nit.contact.views.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, Typeface.BOLD); if (tabTextColorStateList != null) { tab.setTextColor(tabTextColorStateList); } else { tab.setTextColor(tabTextColor); }/*www .j ava 2s .co m*/ if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } else if (v instanceof ViewGroup) { int numChildView = ((ViewGroup) v).getChildCount(); View childView; for (int j = 0; j < numChildView; j++) { childView = ((ViewGroup) v).getChildAt(j); if (childView instanceof TextView) { TextView tab = (TextView) childView; tab.setTypeface(tabTypeface, Typeface.BOLD); if (tabTextColorStateList != null) { tab.setTextColor(tabTextColorStateList); } else { tab.setTextColor(tabTextColor); } // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } } } }
From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.SimpleMonthView.java
/** * Sets up the text and style properties for painting. Override this if you want to use a different paint. *//* w w w. j a va 2 s.co m*/ protected void initView() { mMonthTitlePaint = new Paint(); mMonthTitlePaint.setFakeBoldText(true); mMonthTitlePaint.setAntiAlias(true); mMonthTitlePaint.setTextSize(sMonthLabelTextSize); mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD)); mMonthTitlePaint.setColor(mDayTextColor); mMonthTitlePaint.setTextAlign(Align.CENTER); mMonthTitlePaint.setStyle(Style.FILL); mMonthTitleBGPaint = new Paint(); mMonthTitleBGPaint.setFakeBoldText(true); mMonthTitleBGPaint.setAntiAlias(true); mMonthTitleBGPaint.setColor(mMonthTitleBGColor); mMonthTitleBGPaint.setTextAlign(Align.CENTER); mMonthTitleBGPaint.setStyle(Style.FILL); mSelectedCirclePaint = new Paint(); mSelectedCirclePaint.setFakeBoldText(true); mSelectedCirclePaint.setAntiAlias(true); mSelectedCirclePaint.setColor(mTodayNumberColor); mSelectedCirclePaint.setTextAlign(Align.CENTER); mSelectedCirclePaint.setStyle(Style.FILL); mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA); mMonthDayLabelPaint = new Paint(); mMonthDayLabelPaint.setAntiAlias(true); mMonthDayLabelPaint.setTextSize(sMonthDayLabelTextSize); mMonthDayLabelPaint.setColor(mDayTextColor); mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL)); mMonthDayLabelPaint.setStyle(Style.FILL); mMonthDayLabelPaint.setTextAlign(Align.CENTER); mMonthDayLabelPaint.setFakeBoldText(true); mMonthNumPaint = new Paint(); mMonthNumPaint.setAntiAlias(true); mMonthNumPaint.setTextSize(sMiniDayNumberTextSize); mMonthNumPaint.setStyle(Style.FILL); mMonthNumPaint.setTextAlign(Align.CENTER); mMonthNumPaint.setFakeBoldText(false); }
From source file:com.openerp.addons.messages.Message.java
public void setupListView(List<OEListViewRows> message_list) { // Destroying pre-loaded instance and going to create new one lstview = null;/*from w w w. j a v a 2 s . c om*/ // Fetching required messages for listview by filtering of requrement if (list != null && list.size() <= 0) { list = message_list;// getMessages(message_list); } else { rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE); rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE); } // Handling List View controls and keys String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date", "model|type" }; int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred, R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db, true, new int[] { R.drawable.message_listview_bg_toread_selector, R.drawable.message_listview_bg_tonotread_selector }, "to_read"); // Telling adapter to clean HTML text for key value listAdapter.cleanHtmlToTextOn("body"); listAdapter.cleanDate("date", scope.User().getTimezone()); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) { String model_name = row_data.getRow_data().get("model").toString(); String model = model_name; String res_id = row_data.getRow_data().get("res_id").toString(); if (model_name.equals("false")) { model_name = capitalizeString(row_data.getRow_data().get("type").toString()); } else { String[] model_parts = TextUtils.split(model_name, "\\."); HashSet unique_parts = new HashSet(Arrays.asList(model_parts)); model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray())); } TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag); int tag_color = 0; if (message_model_colors.containsKey(model_name)) { tag_color = message_model_colors.get(model_name); } else { tag_color = Color.parseColor(tag_colors[tag_color_count]); message_model_colors.put(model_name, tag_color); tag_color_count++; if (tag_color_count > tag_colors.length) { tag_color_count = 0; } } if (model.equals("mail.group")) { if (UserGroups.group_names.containsKey("group_" + res_id)) { model_name = UserGroups.group_names.get("group_" + res_id); tag_color = UserGroups.menu_color.get("group_" + res_id); } } msgTag.setBackgroundColor(tag_color); msgTag.setText(model_name); TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject); TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom); if (row_data.getRow_data().get("to_read").toString().equals("false")) { txvSubject.setTypeface(null, Typeface.NORMAL); txvSubject.setTextColor(Color.BLACK); txvAuthor.setTypeface(null, Typeface.NORMAL); txvAuthor.setTextColor(Color.BLACK); } else { txvSubject.setTypeface(null, Typeface.BOLD); txvSubject.setTextColor(Color.parseColor("#414141")); txvAuthor.setTypeface(null, Typeface.BOLD); txvAuthor.setTextColor(Color.parseColor("#414141")); } return row_view; } }); // Creating instance for listview control lstview = (ListView) rootView.findViewById(R.id.lstMessages); // Providing adapter to listview scope.context().runOnUiThread(new Runnable() { @Override public void run() { lstview.setAdapter(listAdapter); } }); // Setting listview choice mode to multiple model lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); // Seeting item long click listern to activate action mode. lstview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) { // TODO Auto-generated method stub OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index); Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show(); view.setSelected(true); if (mActionMode != null) { return false; } // Start the CAB using the ActionMode.Callback defined above mActionMode = scope.context().startActionMode(mActionModeCallback); selectedCounter++; view.setBackgroundResource(R.drawable.listitem_pressed); // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); return true; } }); // Setting multi choice selection listener lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() { HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>(); @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are // selected/de-selected, // such as update the title in the CAB selectedList.put(position, checked); if (checked) { selectedCounter++; } else { selectedCounter--; } if (selectedCounter != 0) { mode.setTitle(selectedCounter + ""); } } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>(); OEDialog dialog = null; switch (item.getItemId()) { case R.id.menu_message_mark_unread_selected: Log.e("menu_message_context", "Mark as Unread"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_mark_read_selected: Log.e("menu_message_context", "Mark as Read"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_move_to_archive_selected: Log.e("menu_message_context", "Archive"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_add_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, true); markasTodoTask.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_remove_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, false); markasTodoTask.execute((Void) null); mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_fragment_message_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are // deselected/unchecked. /* * Perform Operation on Selected Ids. * * row_ids are list of selected message Ids. */ selectedList.clear(); selectedCounter = 0; lstview.clearChoices(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } }); lstview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int index, long id) { // TODO Auto-generated method stub MessageDetail messageDetail = new MessageDetail(); Bundle bundle = new Bundle(); bundle.putInt("message_id", list.get(index).getRow_id()); bundle.putInt("position", index); messageDetail.setArguments(bundle); scope.context().fragmentHandler.setBackStack(true, null); scope.context().fragmentHandler.replaceFragmnet(messageDetail); if (!type.equals("archive")) { list.remove(index); } listAdapter.refresh(list); } }); // Getting Pull To Refresh Attacher from Main Activity mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher(); // Set the Refreshable View to be the ListView and the refresh listener // to be this. if (mPullToRefreshAttacher != null & lstview != null) { mPullToRefreshAttacher.setRefreshableView(lstview, this); } }
From source file:com.android.contacts.common.list.ContactListItemView.java
public ContactListItemView(Context context) { super(context); mTextHighlighter = new TextHighlighter(Typeface.BOLD); mNameHighlightSequence = new ArrayList<HighlightSequence>(); mNumberHighlightSequence = new ArrayList<HighlightSequence>(); }
From source file:com.maedi.user.godok.v1.viewpagerindicator.TabPageIndicator.java
@SuppressLint("ResourceAsColor") private void changeTabLayout(int item, String title) { PagerAdapter adapter = mViewPager.getAdapter(); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); if (i == 1) child.setBackgroundResource(R.drawable.tab_view);//child.setPadding(0, 0, 10, 0);//L,T,R,B ((TextView) child).setTypeface(Typeface.DEFAULT, Typeface.NORMAL); //((TextView) child).setTextColor(getResources().getColor(R.color.tab_button_text)); ((TextView) child).setTextSize(15); ((TextView) child).setGravity(Gravity.CENTER); ((TextView) child).setTextColor(getResources().getColor(R.color.white)); /*//from w ww. j av a 2s .c om * for advance menu left selected * by medi */ if (null != title && !title.equalsIgnoreCase("")) { CharSequence originalTitle = adapter.getPageTitle(i); ((TextView) child).setText(originalTitle); } final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); ((TextView) child).setTypeface(Typeface.DEFAULT, Typeface.BOLD); //((TextView) child).setTextColor(getResources().getColor(R.color.tab_button_text_selected)); if (null != title && !title.equalsIgnoreCase("")) { ((TextView) child).setText(title); } } } }
From source file:io.github.hidroh.materialistic.data.HackerNewsItem.java
@NonNull private SpannableString createAuthorSpannable(boolean authorLink) { SpannableString bySpannable = new SpannableString(AUTHOR_SEPARATOR + by); if (!authorLink) { return bySpannable; }/*from ww w .j av a 2 s . c om*/ bySpannable.setSpan(new StyleSpan(Typeface.BOLD), AUTHOR_SEPARATOR.length(), bySpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View view) { view.getContext() .startActivity(new Intent(Intent.ACTION_VIEW).setData(AppUtils.createUserUri(getBy()))); } @Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); ds.setUnderlineText(false); } }; bySpannable.setSpan(clickableSpan, AUTHOR_SEPARATOR.length(), bySpannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); return bySpannable; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE TEXT ROW// w ww . j ava 2 s.c om * @param att * @param linear * @return */ public LinearLayout getSingleTextRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView t2 = new TextView(context); t2.setText(att.get("value").equals("") ? " - " : att.get("value")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t2, value_params); linear.addView(container_layout); return linear; }