List of usage examples for android.widget TextView setTextSize
@android.view.RemotableViewMethod public void setTextSize(float size)
From source file:cn.ucai.superwechat.adapter.MessageAdapter.java
@SuppressWarnings("ResourceType") private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) { try {// w w w.j a v a 2s .c om parentView.removeAllViews(); for (int i = 0; i < jsonArr.length(); i++) { final String itemStr = jsonArr.getString(i); final TextView textView = new TextView(context); textView.setText(itemStr); textView.setTextSize(15); try { XmlPullParser xrp = context.getResources() .getXml(cn.ucai.superwechat.R.drawable.menu_msg_text_color); textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp)); } catch (Exception e) { e.printStackTrace(); } textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ChatActivity) context).sendText(itemStr); } }); LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llLp.bottomMargin = DensityUtil.dip2px(context, 3); llLp.topMargin = DensityUtil.dip2px(context, 3); parentView.addView(textView, llLp); } } catch (JSONException e) { e.printStackTrace(); } }
From source file:bill.billmanager.Adapters.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w w w. j av a 2 s .c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } // Sets tab's text color and size tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); tabTitleView.setTextSize(14); } }
From source file:com.easemob.chatui.adapter.MessageAdapter.java
private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) { try {//from w ww . j a v a2 s . c o m parentView.removeAllViews(); for (int i = 0; i < jsonArr.length(); i++) { final String itemStr = jsonArr.getString(i); final TextView textView = new TextView(context); textView.setText(itemStr); textView.setTextSize(15); try { XmlPullParser xrp = context.getResources().getXml(R.drawable.menu_msg_text_color); textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp)); } catch (Exception e) { e.printStackTrace(); } textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((ChatActivity) context).sendText(itemStr); } }); LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llLp.bottomMargin = DensityUtil.dip2px(context, 3); llLp.topMargin = DensityUtil.dip2px(context, 3); parentView.addView(textView, llLp); } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.farmerbb.notepad.adapter.NoteListDateAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position NoteListItem item = getItem(position); String note = item.getNote(); String date = item.getDate(); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false); // Lookup view for data population TextView noteTitle = convertView.findViewById(R.id.noteTitle); TextView noteDate = convertView.findViewById(R.id.noteDate); // Populate the data into the template view using the data object noteTitle.setText(note);//from w w w . j a va 2 s . c o m noteDate.setText(date); // Apply theme SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary)); } if (theme.contains("dark")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark)); } if (theme.contains("sans")) { noteTitle.setTypeface(Typeface.SANS_SERIF); noteDate.setTypeface(Typeface.SANS_SERIF); } if (theme.contains("serif")) { noteTitle.setTypeface(Typeface.SERIF); noteDate.setTypeface(Typeface.SERIF); } if (theme.contains("monospace")) { noteTitle.setTypeface(Typeface.MONOSPACE); noteDate.setTypeface(Typeface.MONOSPACE); } switch (pref.getString("font_size", "normal")) { case "smallest": noteTitle.setTextSize(12); noteDate.setTextSize(8); break; case "small": noteTitle.setTextSize(14); noteDate.setTextSize(10); break; case "normal": noteTitle.setTextSize(16); noteDate.setTextSize(12); break; case "large": noteTitle.setTextSize(18); noteDate.setTextSize(14); break; case "largest": noteTitle.setTextSize(20); noteDate.setTextSize(16); break; } // Return the completed view to render on screen return convertView; }
From source file:terse.a1.TerseActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); glSurfaceView = null; // Forget gl on new activity. requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); if (savedInstanceState != null && savedInstanceState.containsKey("TerseActivity")) { taSaveMe = savedInstanceState.getString("TerseActivity"); } else {/*from w w w. j a v a 2s . c o m*/ taSaveMe = null; } Runnable bg = new Runnable() { @Override public void run() { resetTerp(); } }; Runnable fg = new Runnable() { @Override public void run() { Intent intent = getIntent(); Uri uri = intent.getData(); Bundle extras = intent.getExtras(); String path = uri == null ? "/" : uri.getPath(); String query = uri == null ? "" : uri.getQuery(); viewPath(path, query, extras, savedInstanceState); } }; if (terp == null) { TextView tv = new TextView(TerseActivity.this); tv.setText(Static.fmt("Building new TerseTalk VM for world <%s>...", world)); tv.setTextAppearance(this, R.style.teletype); tv.setBackgroundColor(Color.BLACK); tv.setTextColor(Color.DKGRAY); tv.setTextSize(24); setContentView(tv); setContentViewThenBgThenFg("ResetSplash", tv, bg, fg); } else { fg.run(); } }
From source file:terse.a1.TerseActivity.java
public void viewPath(String path, String queryStr, Bundle extras, Bundle savedInstanceState) { // Stop any running WorkThread before we continue. viewPath1prepare(path, queryStr);/*from w w w .j ava 2s.c o m*/ viewPath2parseQuery(queryStr, extras); final LayoutParams widgetParams = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 1.0f); TextView splash = new TextView(TerseActivity.this); splash.setText("Launching\n\n" + taPath + "\n\n" + Static.hashMapToMultiLineString(taQuery)); splash.setTextAppearance(this, R.style.teletype); splash.setBackgroundColor(Color.BLACK); splash.setTextColor(Color.DKGRAY); splash.setTextSize(24); Runnable bg = new Runnable() { @Override public void run() { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } }; Runnable fg = new Runnable() { @Override public void run() { viewPath9display(taPath, widgetParams); } }; setContentViewThenBgThenFg("viewPath8", splash, bg, fg); }
From source file:com.antonborries.bulktask.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* w w w . j a va2s .co m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTag("titleView_" + String.valueOf(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); tabTitleView.setTextSize(14); } }
From source file:com.anjalimacwan.adapter.NoteListDateAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position NoteListItem item = getItem(position); String note = item.getNote(); String date = item.getDate(); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false); // Lookup view for data population TextView noteTitle = (TextView) convertView.findViewById(R.id.noteTitle); TextView noteDate = (TextView) convertView.findViewById(R.id.noteDate); // Populate the data into the template view using the data object noteTitle.setText(note);//from w w w . jav a2s.co m noteDate.setText(date); // Apply theme SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary)); } if (theme.contains("dark")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark)); } if (theme.contains("sans")) { noteTitle.setTypeface(Typeface.SANS_SERIF); noteDate.setTypeface(Typeface.SANS_SERIF); } if (theme.contains("serif")) { noteTitle.setTypeface(Typeface.SERIF); noteDate.setTypeface(Typeface.SERIF); } if (theme.contains("monospace")) { noteTitle.setTypeface(Typeface.MONOSPACE); noteDate.setTypeface(Typeface.MONOSPACE); } switch (pref.getString("font_size", "normal")) { case "smallest": noteTitle.setTextSize(12); noteDate.setTextSize(8); break; case "small": noteTitle.setTextSize(14); noteDate.setTextSize(10); break; case "normal": noteTitle.setTextSize(16); noteDate.setTextSize(12); break; case "large": noteTitle.setTextSize(18); noteDate.setTextSize(14); break; case "largest": noteTitle.setTextSize(20); noteDate.setTextSize(16); break; } // Return the completed view to render on screen return convertView; }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** initAddDestButton() * adds the Driving Through button// w w w. ja va 2 s . c o m */ protected void initAddDestButton() { //Adds/enables the FrameLayout AddDestFrameLayout = new FrameLayout(this); AddDestFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, 80)); AddDestFrameLayout.setEnabled(true); //Fills the Image Icon ImageView destAddIcon = new ImageView(this); FrameLayout.LayoutParams lliDestIcon = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lliDestIcon.setMargins(dipToPx(10), 0, 0, dipToPx(2)); destAddIcon.setLayoutParams(lliDestIcon); destAddIcon.setPadding(0, dipToPx(5), 0, 0); destAddIcon.setImageResource(R.drawable.google_marker_thumb_mini_through); //Adds the imageicon to the framelayout/enables it AddDestFrameLayout.addView(destAddIcon); //Fills/sets the text TextView destAddText = new TextView(this); FrameLayout.LayoutParams lliDest = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lliDest.setMargins(0, dipToPx(5), 0, 0); destAddText.setLayoutParams(lliDest); destAddText.setPadding(dipToPx(40), dipToPx(6), 0, 0); destAddText.setTextSize(15); destAddText.setText(R.string.mapViewAcField); //Adds the text to the framelayout AddDestFrameLayout.addView(destAddText); //Adds the framelayout to the linearlayout (in the scrollview) sclLayout = (LinearLayout) findViewById(R.id.sclLayout); sclLayout.addView(AddDestFrameLayout, sclLayout.getChildCount()); final Button button = ((Button) findViewById(R.id.btnChooseRoute)); //Adds a clicklistener to the frameLayout AddDestFrameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //Adds a new destination field initDestFrameLayout(); //Moves the button to the bottom setLayoutParams(); if (checkFields() == false) { button.setEnabled(false); button.setText("Show on map"); } else { mapView.getOverlays().clear(); createMap(); } } }); }
From source file:net.phase.wallet.Currency.java
@Override public View getView(int position, View convertView, ViewGroup parent) { double exchrate = Currency.getRate(context.getActiveCurrency()); LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.walletlayout, null); v.setLongClickable(true);// www . ja v a2s .c om v.setOnClickListener(context); v.setTag(position); DecimalFormat df = new DecimalFormat(WalletActivity.decimalString(decimalpoints)); TextView balanceTextView = (TextView) v.findViewById(R.id.walletBalanceText); balanceTextView.setText(df.format(wallets[position].balance / BalanceRetriever.SATOSHIS_PER_BITCOIN)); TextView curTextView = (TextView) v.findViewById(R.id.walletCurText); curTextView.setTextSize(10); if (exchrate != 0) { curTextView.setText( "(" + df.format(wallets[position].balance * exchrate / BalanceRetriever.SATOSHIS_PER_BITCOIN) + context.getActiveCurrency() + ")"); } else { curTextView.setText(""); } balanceTextView.setTextSize(20); balanceTextView.setTextColor(Color.GREEN); TextView nameTextView = (TextView) v.findViewById(R.id.walletNameText); nameTextView.setText(wallets[position].name); nameTextView.setTextColor(Color.BLACK); nameTextView.setTextSize(16); TextView lastUpdatedTextView = (TextView) v.findViewById(R.id.lastUpdatedText); lastUpdatedTextView.setTextColor(Color.GRAY); lastUpdatedTextView.setTextSize(8); lastUpdatedTextView.setText("Last Updated: " + getTimeStampString(wallets[position].lastUpdated)); TextView infoTextView = (TextView) v.findViewById(R.id.infoText); infoTextView.setTextColor(Color.GRAY); infoTextView.setTextSize(8); infoTextView.setText( wallets[position].keys.length + " keys (" + wallets[position].getActiveKeyCount() + " in use)"); TextView txLastUpdatedTextView = (TextView) v.findViewById(R.id.txLastUpdatedText); txLastUpdatedTextView.setTextColor(Color.GRAY); txLastUpdatedTextView.setTextSize(8); TextView txInfoTextView = (TextView) v.findViewById(R.id.txInfoText); txInfoTextView.setTextColor(Color.GRAY); txInfoTextView.setTextSize(8); if (wallets[position].transactions != null && wallets[position].transactions.length > 0) { txLastUpdatedTextView.setText( "Last Transaction: " + getTimeStampString(Transaction.latest(wallets[position].transactions))); txInfoTextView.setText(wallets[position].transactions.length + " transactions (" + Transaction.compressTransactions(wallets[position].transactions).length + " unique)"); } else { txLastUpdatedTextView.setText(""); txInfoTextView.setText(""); } Button button = (Button) v.findViewById(R.id.updateButton); button.setTag(position); button.setOnClickListener(context); return v; }