List of usage examples for android.graphics Paint SUBPIXEL_TEXT_FLAG
int SUBPIXEL_TEXT_FLAG
To view the source code for android.graphics Paint SUBPIXEL_TEXT_FLAG.
Click Source Link
From source file:android.support.design.widget.SubtitleCollapsingTextHelper.java
public SubtitleCollapsingTextHelper(View view) { mView = view;/*from w w w . java2 s . c om*/ mTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:com.muzakki.ahmad.widget.CollapsingTextHelper.java
public CollapsingTextHelper(View view) { mView = view;// www .j ava2 s . c o m mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); // modification mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:android.support.design.widget.CustomCollapsingTextHelper.java
public CustomCollapsingTextHelper(View view) { mView = view;//from ww w. j a v a 2 s . c om mTitlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mSubPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mCollapsedBounds = new Rect(); mExpandedBounds = new Rect(); mCurrentBounds = new RectF(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.AddToPlaylistDialog.java
public void showNewPlaylistDialog() { View dialogView = getActivity().getLayoutInflater().inflate(R.layout.add_new_playlist_dialog_layout, null); final EditText newPlaylistEditText = (EditText) dialogView.findViewById(R.id.new_playlist_name_text_field); newPlaylistEditText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); newPlaylistEditText.setPaintFlags(/*from w ww. jav a 2 s . c o m*/ newPlaylistEditText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.new_playlist); builder.setView(dialogView); builder.setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Retrieve the name of the new playlist. String playlistName = newPlaylistEditText.getText().toString(); AsyncCreateNewPlaylistTask task = new AsyncCreateNewPlaylistTask(mContext, playlistName, ARTIST, ALBUM, SONG, GENRE, ALBUM_ARTIST, ADD_TYPE); task.execute(); dialog.dismiss(); } }); builder.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:com.dictionary.codebhak.LangTextView.java
/** * Sets the typeface to the value selected in the preference. * @param context the {@link Context} to use */// ww w.jav a 2 s . co m private void setTypeface(Context context) { if (robotoTypefacePreferenceSet(context)) { setTypeface(Typeface.DEFAULT); } else if (!isInEditMode() && !TextUtils.isEmpty(NOTO_SERIF)) { Typeface typeface = sTypefaceCache.get(NOTO_SERIF); if (typeface == null) { typeface = Typeface.createFromAsset(context.getAssets(), "fonts/" + NOTO_SERIF); // Cache the Typeface object sTypefaceCache.put(NOTO_SERIF, typeface); } setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } }
From source file:enterprayz.megatools.Tools.java
public static int getTextHeight(String text, int maxWidth, float textSize, Typeface typeface) { TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); paint.setTextSize(textSize);//from ww w . java 2s . c o m paint.setTypeface(typeface); int lineCount = 0; int index = 0; int length = text.length(); while (index < length - 1) { index += paint.breakText(text, index, length, true, maxWidth, null); lineCount++; } Rect bounds = new Rect(); paint.getTextBounds("Py", 0, 2, bounds); return (int) Math.floor(lineCount * bounds.height()); }
From source file:com.jams.music.player.GridViewFragment.GridViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = inflater.inflate(R.layout.fragment_grid_view, container, false); mContext = getActivity().getApplicationContext(); mApp = (Common) mContext;//from www. j a va 2 s. c om mFragment = this; //Set the background color and the partial color bleed. mRootView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext)); //Grab the fragment. This will determine which data to load into the cursor. mFragmentId = getArguments().getInt(Common.FRAGMENT_ID); mFragmentTitle = getArguments().getString(MainActivity.FRAGMENT_HEADER); mDBColumnsMap = new HashMap<Integer, String>(); mQuickScroll = (QuickScrollGridView) mRootView.findViewById(R.id.quickscrollgrid); //Set the adapter for the outer gridview. mGridView = (GridView) mRootView.findViewById(R.id.generalGridView); mGridViewContainer = (RelativeLayout) mRootView.findViewById(R.id.fragment_grid_view_frontal_layout); mGridView.setVerticalScrollBarEnabled(false); //Set the number of gridview columns based on the screen density and orientation. if (mApp.isPhoneInLandscape() || mApp.isTabletInLandscape()) { mGridView.setNumColumns(4); } else if (mApp.isPhoneInPortrait()) { mGridView.setNumColumns(3);//Test only, 2 } else if (mApp.isTabletInPortrait()) { mGridView.setNumColumns(3); } //KitKat translucent navigation/status bar. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int topPadding = Common.getStatusBarHeight(mContext); //Calculate navigation bar height. int navigationBarHeight = 0; int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigationBarHeight = getResources().getDimensionPixelSize(resourceId); } mGridViewContainer.setPadding(0, topPadding, 0, 0); mGridView.setClipToPadding(false); mGridView.setPadding(0, mGridView.getPaddingTop(), 0, navigationBarHeight); mQuickScroll.setPadding(0, 0, 0, navigationBarHeight); } //Set the empty views. mEmptyTextView = (TextView) mRootView.findViewById(R.id.empty_view_text); mEmptyTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light")); mEmptyTextView .setPaintFlags(mEmptyTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Create a set of options to optimize the bitmap memory usage. final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; options.inJustDecodeBounds = false; options.inPurgeable = true; mHandler.postDelayed(queryRunnable, 250); return mRootView; }
From source file:com.aniruddhc.acemusic.player.GridViewFragment.GridViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = inflater.inflate(R.layout.fragment_grid_view, container, false); mContext = getActivity().getApplicationContext(); mApp = (Common) mContext;/*from w w w. j av a 2 s . com*/ mFragment = this; //Set the background color and the partial color bleed. mRootView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext)); //Grab the fragment. This will determine which data to load into the cursor. mFragmentId = getArguments().getInt(Common.FRAGMENT_ID); mFragmentTitle = getArguments().getString(MainActivity.FRAGMENT_HEADER); mDBColumnsMap = new HashMap<Integer, String>(); mQuickScroll = (QuickScrollGridView) mRootView.findViewById(R.id.quickscrollgrid); //Set the adapter for the outer gridview. mGridView = (GridView) mRootView.findViewById(R.id.generalGridView); mGridViewContainer = (RelativeLayout) mRootView.findViewById(R.id.fragment_grid_view_frontal_layout); mGridView.setVerticalScrollBarEnabled(false); //Set the number of gridview columns based on the screen density and orientation. if (mApp.isPhoneInLandscape() || mApp.isTabletInLandscape()) { mGridView.setNumColumns(4); } else if (mApp.isPhoneInPortrait()) { mGridView.setNumColumns(2); } else if (mApp.isTabletInPortrait()) { mGridView.setNumColumns(3); } //KitKat translucent navigation/status bar. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int topPadding = Common.getStatusBarHeight(mContext); //Calculate navigation bar height. int navigationBarHeight = 0; int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigationBarHeight = getResources().getDimensionPixelSize(resourceId); } mGridViewContainer.setPadding(0, topPadding, 0, 0); mGridView.setClipToPadding(false); mGridView.setPadding(0, mGridView.getPaddingTop(), 0, navigationBarHeight); mQuickScroll.setPadding(0, 0, 0, navigationBarHeight); } //Set the empty views. mEmptyTextView = (TextView) mRootView.findViewById(R.id.empty_view_text); mEmptyTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light")); mEmptyTextView .setPaintFlags(mEmptyTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Create a set of options to optimize the bitmap memory usage. final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; options.inJustDecodeBounds = false; options.inPurgeable = true; mHandler.postDelayed(queryRunnable, 250); return mRootView; }
From source file:com.justwayward.reader.view.recyclerview.adapter.BaseViewHolder.java
public BaseViewHolder setTypeface(int viewId, Typeface typeface) { TextView view = getView(viewId);//from w w w .j av a 2 s.c o m view.setTypeface(typeface); view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); return this; }
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 ww w . ja v a2 s . com*/ } 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; }