guyafe

Untitled

Nov 6th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  2.             Bundle savedInstanceState) {
  3.  
  4.         AssetManager manager = m_dataCreator.getAssetManager(); //This is a provider for several resources
  5.         View view = inflater.inflate(R.layout.chapter_layout, container, false);
  6.         TextView dataView = (TextView)view.findViewById(R.id.chapter_data_view);
  7.        
  8.         //m_data is of type SpanableStringBuilder
  9.         RelativeSizeSpan sa = new RelativeSizeSpan(4f);
  10.         m_data.setSpan(sa, 1, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); //Works well
  11.         m_data.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 40, 50, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); //works well
  12.         m_data.setSpan(Typeface.createFromAsset(manager, "fonts/TaameyAshkenaz-MediumOblique.ttf"),
  13.                 10,
  14.                 20,
  15.                 Spannable.SPAN_INCLUSIVE_INCLUSIVE); //Doesn't work
  16.        
  17.         //dataView.setTypeface(Typeface.createFromAsset(manager, "fonts/TaameyAshkenaz-MediumOblique.ttf"));
  18. //This would also work well if I will unmark it.
  19.        
  20.         dataView.setText(m_data, BufferType.SPANNABLE);
  21.        
  22.         return view;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment