List of usage examples for android.widget TextView setTextSize
public void setTextSize(int unit, float size)
From source file:com.benefit.buy.library.viewpagerindicator.PagerSlidingTabStrip.java
@SuppressLint("NewApi") private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); 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 w w w . jav a 2 s .co m } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); } } else { View vImg = v.findViewById(R.id.img_click); View vText = v.findViewById(R.id.tab_name); if (vText instanceof TextView) { TextView tab = (TextView) vText; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); 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)); } } } if (vImg instanceof ImageView) { ImageView img = (ImageView) vImg; if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { if ((i == selectedPosition) || (i == (selectedPosition + 1)) || (i == (selectedPosition - 1))) { // tab.setTextColor(selectedTabTextColor); img.setAlpha(0f); img.setVisibility(View.VISIBLE); } else { img.setVisibility(View.INVISIBLE); } } else { if ((i == selectedPosition)) { // tab.setTextColor(selectedTabTextColor); img.setVisibility(View.VISIBLE); } else { img.setVisibility(View.INVISIBLE); } } } } } }
From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java
public void initTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); 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 w w w .ja va 2s .c om*/ } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); if (oldTab != null) { oldTab.setSelected(false); ((TextView) oldTab).setTextColor(tabTextColor); } oldTab = tab; tab.setSelected(true); } } } }
From source file:edu.rowan.app.carousel.CarouselFeature.java
private void setupView() { imageView.setId(1);/*from ww w .java2s . c o m*/ RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); imageView.setLayoutParams(imageParams); // imageView.setAdjustViewBounds(true); Resources r = context.getResources(); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); TextView descriptionView = new TextView(context); descriptionView.setId(2); descriptionView.setPadding(padding, 0, padding, padding); descriptionView.setText(description); descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10)); descriptionView.setTextColor(Color.WHITE); RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId()); carouselView.addView(descriptionView, descParams); TextView titleView = new TextView(context); titleView.setText(title); titleView.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId()); titleView.setLayoutParams(titleParams); titleView.setTextColor(Color.WHITE); titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0)); titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); carouselView.addView(titleView); }
From source file:cc.wudoumi.framework.views.PagerSlidingTabStrip.java
private void updateTabTextSize(TextView tab) { if (tabTextSizeChange) { if (tab.isSelected()) { tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selecttabTextSize); } else {// w ww. j a v a 2 s . co m tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); } } }
From source file:com.astuetz.PagerSlidingTabStripPlus.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { for (int k = 0; k < ((LinearLayout) tabsContainer.getChildAt(i)).getChildCount(); k++) { View v = ((LinearLayout) tabsContainer.getChildAt(i)).getChildAt(k); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); // Setting color of textView if (textColorTab != null) { tab.setTextColor(textColorTab); } else { tab.setTextColor(Color.BLACK); }// w w w. j ava 2 s.c o m // 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.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { FrameLayout frameLayout = (FrameLayout) tabsContainer.getChildAt(i); frameLayout.setBackgroundResource(tabBackgroundResId); for (int j = 0; j < frameLayout.getChildCount(); j++) { View v = frameLayout.getChildAt(j); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (j == 0) { tab.setTextColor(tabTextColor); } else { tab.setTextColor(selectedTabTextColor); }// w w w . jav a 2 s . co m ViewHelper.setAlpha(tabViews.get(i).get("normal"), 1); ViewHelper.setAlpha(tabViews.get(i).get("selected"), 0); //set normal Scale ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f); ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f); ViewHelper.setScaleX(frameLayout, 1f); ViewHelper.setScaleY(frameLayout, 1f); // 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)); } } if (i == selectedPosition) { ViewHelper.setAlpha(tabViews.get(i).get("normal"), 0); ViewHelper.setAlpha(tabViews.get(i).get("selected"), 1); //set select Scale ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f); ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f); ViewHelper.setScaleX(frameLayout, 1 + zoomMax); ViewHelper.setScaleY(frameLayout, 1 + zoomMax); } } } } }
From source file:com.asc_ii.bangnote.bigbang.BigBangLayout.java
public void addTextItem(String text) { TextView view = new TextView(getContext()); view.setText(text);// w w w .j a v a2s . com view.setBackgroundResource(R.drawable.item_background); view.setTextColor(ContextCompat.getColorStateList(getContext(), R.color.bigbang_item_text)); view.setGravity(Gravity.CENTER); if (mItemTextSize > 0) view.setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemTextSize); addView(view); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
/** * Refreshes funds table with fetched data * * @param response JSONObject with funds data *//* w ww . j av a2 s .c o m*/ private void refreshFunds(JSONObject response) { try { if (response == null) { Toast.makeText(getActivity(), getResources().getString(R.string.GeneralErrorText), Toast.LENGTH_LONG).show(); return; } String notificationText; if (response.getInt("success") == 1) { View.OnClickListener fillAmount = new View.OnClickListener() { @Override public void onClick(View v) { ScrollView scrollView = (ScrollView) getView(); if (scrollView != null) { EditText tradeAmount = (EditText) scrollView.findViewById(R.id.TradeAmount); tradeAmount.setText(((TextView) v).getText()); scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom()); } } }; notificationText = getResources().getString(R.string.FundsInfoUpdatedtext); TableLayout fundsContainer = (TableLayout) getView().findViewById(R.id.FundsContainer); fundsContainer.removeAllViews(); JSONObject funds = response.getJSONObject("return").getJSONObject("funds"); JSONArray fundsNames = response.getJSONObject("return").getJSONObject("funds").names(); List<String> arrayList = new ArrayList<>(); for (int i = 0; i < fundsNames.length(); i++) { arrayList.add(fundsNames.getString(i)); } Collections.sort(arrayList); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); for (String anArrayList : arrayList) { TableRow row = new TableRow(getActivity()); TextView currency = new TextView(getActivity()); TextView amount = new TextView(getActivity()); currency.setText(anArrayList.toUpperCase(Locale.US)); amount.setText(funds.getString(anArrayList)); currency.setLayoutParams(layoutParams); currency.setTypeface(Typeface.DEFAULT, Typeface.BOLD); currency.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); currency.setGravity(Gravity.CENTER); amount.setLayoutParams(layoutParams); amount.setGravity(Gravity.CENTER); amount.setOnClickListener(fillAmount); row.addView(currency); row.addView(amount); fundsContainer.addView(row); } } else { notificationText = response.getString("error"); } mCallback.makeNotification(ConstantHolder.ACCOUNT_INFO_NOTIF_ID, notificationText); } catch (JSONException e) { e.printStackTrace(); } }
From source file:be.blinkt.openvpn.views.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); TextView tab_title = (TextView) v.findViewById(R.id.tab_title); if (tab_title != null) { tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle); if (tabTextColor != null) { tab_title.setTextColor(tabTextColor); }/*from w w w .j av a 2 s. c o m*/ // 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_title.setAllCaps(true); } else { tab_title.setText(tab_title.getText().toString().toUpperCase(locale)); } } } } }
From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java
@Override public View getView(int position, View convertView, ViewGroup parent) { TextView txt = (TextView) convertView; if (txt == null) { txt = new TextView(getApplication()); txt.setPadding(UI._8dp, UI._4dp, UI._8dp, UI._4dp); txt.setTypeface(UI.defaultTypeface); txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); txt.setTextColor(defaultTextColors); }/* w w w.ja va 2 s .c o m*/ txt.setText(getGenreString(position)); return txt; }