List of usage examples for android.widget TextView setTextSize
public void setTextSize(int unit, float size)
From source file:com.example.view.astuetz.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; android.widget.LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1f); tab.setLayoutParams(layoutParams); 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 ww w.j a va 2 s . c o m*/ } } } }
From source file:zxing.util.CaptureActivity.java
License:asdf
/** * A valid barcode has been found, so give an indication of success and show * the results./*www . j a va 2 s. co m*/ * * @param rawResult * The contents of the barcode. * @param scaleFactor * amount by which thumbnail was scaled * @param barcode * A greyscale bitmap of the camera data which was decoded. */ public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) { inactivityTimer.onActivity(); //lastResult = rawResult; String url = "http://192.168.1.105:8080/ExTraceWebService_war/REST/Domain"; beepManager.playBeepSoundAndVibrate(); String resultString = rawResult.getText(); Intent mIntent = getIntent(); if (mIntent.getStringExtra("Action").equals("Pkg")) { switch (Integer.parseInt(mIntent.getStringExtra("role").toString().substring(0, 1))) { //( // case 1: Log.i("teasdfjsadf", mIntent.getStringExtra("role").toString()); if (resultString.startsWith("1")) { url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); startOnePkgExp(url);// // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else if (resultString.startsWith("8")) { url = url + "/dispatchExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); changePkgToStatus4(url);// break; } else { break; } // case 2: if (resultString.startsWith("8")) { url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); startOnePkgExp(url);// // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } break; // case 3: if (resultString.startsWith("1")) { url = url + "/packTransPackage/PackageID/" + "8001" + "/ExpressID/" + resultString; // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else if (resultString.startsWith("8")) { url = url + "/unpackTransPackage/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); break; } else { break; } } } else if (mIntent.getStringExtra("Action").equals("exp")) { // switch (Integer.parseInt(mIntent.getStringExtra("role"))) { case 1: //finsh(); break; case 2: if (resultString.startsWith("8")) { url = url + "/unpackTransPackage/" + "8001"; // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else { } //finsh(); break; // case 3: } } drawResultPoints(barcode, scaleFactor, rawResult); statusView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); resultView.setVisibility(View.VISIBLE); ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view); if (barcode == null) { barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.launcher_icon)); } else { barcodeImageView.setImageBitmap(barcode); } ParsedResult result = ResultParser.parseResult(rawResult); String contents = result.getDisplayResult().replace("\r", ""); CharSequence displayContents = contents; lastResult = contents; TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view); contentsTextView.setText(displayContents); int scaledSize = Math.max(22, 32 - displayContents.length() / 4); contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); }
From source file:com.cloudTop.starshare.ui.wangyi.common.ui.viewpager.PagerSlidingTabStrip.java
private void addTabView(final int position, String title) { View tabView = null;//w w w . jav a 2 s . c om boolean screenAdaptation = false; final LayoutInflater inflater = LayoutInflater.from(getContext()); if (this.onCustomTabListener != null) { int tabResId = onCustomTabListener.getTabLayoutResId(position); if (tabResId != 0) { tabView = inflater.inflate(tabResId, null); } else { tabView = onCustomTabListener.getTabLayoutView(inflater, position); } screenAdaptation = onCustomTabListener.screenAdaptation(); } if (tabView == null) { tabView = inflater.inflate(R.layout.tab_layout_main, null); } TextView titleTV = ((TextView) tabView.findViewById(R.id.tab_title_label)); final boolean needAdaptation = ScreenUtil.density <= 1.5 && screenAdaptation; final Resources resources = getContext().getResources(); if (titleTV != null) { titleTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_11) : resources.getDimensionPixelSize(R.dimen.text_size_15)); titleTV.setText(title); } final DropFake unreadTV = ((DropFake) tabView.findViewById(R.id.tab_new_msg_label)); if (unreadTV != null) { unreadTV.setTouchListener(new DropFake.ITouchListener() { @Override public void onDown() { DropManager.getInstance().setCurrentId(String.valueOf(position)); DropManager.getInstance().down(unreadTV, unreadTV.getText()); } @Override public void onMove(float curX, float curY) { DropManager.getInstance().move(curX, curY); } @Override public void onUp() { DropManager.getInstance().up(); } }); //unreadTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_9) : resources.getDimensionPixelSize(R.dimen.text_size_12)); } addTab(position, tabView); }
From source file:com.bei.test.view.tab.PagerSlidingTabStrip.java
private void select(View tab) { if (tab != null) { TextView tab_title = (TextView) tab.findViewById(R.id.psts_tab_title); if (tab_title != null) { tab_title.setSelected(true); tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabSelectTextSize); }/* w ww. j av a 2s .co m*/ if (isCustomTabs) ((CustomTabProvider) mPager.getAdapter()).tabSelected(tab); } }
From source file:com.bei.test.view.tab.PagerSlidingTabStrip.java
private void unSelect(View tab) { if (tab != null) { TextView tab_title = (TextView) tab.findViewById(R.id.psts_tab_title); if (tab_title != null) { tab_title.setSelected(false); tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabNormalTextSize); }/* w ww .j a va 2s.c o m*/ if (isCustomTabs) ((CustomTabProvider) mPager.getAdapter()).tabUnselected(tab); } }
From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);//from w w w . j ava2 s . c o m textView.setBackgroundResource(R.drawable.view_pager_tab_background); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); textView.setOnLongClickListener(new OnTabLongClickListener(position)); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:cn.hollo.www.custom_view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title, int leftIcon) { TextView tab = new TextView(getContext()); tab.setText(title);// ww w. ja v a 2 s .c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); if (tabTextColor != null) tab.setTextColor(tabTextColor); else tab.setTextColor(defaultTabTextColor); tab.setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, 0, 0); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java
public TextView getTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);// w w w . j av a 2s . com tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(getResources().getColorStateList( mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector)); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (null != mOnPageClickedLisener) { mOnPageClickedLisener.onPageClicked(position); } pager.setCurrentItem(position); } }); return tab; }
From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java
private void addTabView(final int position, String title) { View tabView = null;/*from w w w . j ava 2s . c om*/ boolean screenAdaptation = false; final LayoutInflater inflater = LayoutInflater.from(getContext()); if (this.onCustomTabListener != null) { int tabResId = onCustomTabListener.getTabLayoutResId(position); if (tabResId != 0) { tabView = inflater.inflate(tabResId, null); } else { tabView = onCustomTabListener.getTabLayoutView(inflater, position); } screenAdaptation = onCustomTabListener.screenAdaptation(); } if (tabView == null) { tabView = inflater.inflate(R.layout.tab_layout_main, null); } TextView titltTV = ((TextView) tabView.findViewById(R.id.tab_title_label)); TextView unreadTV = ((TextView) tabView.findViewById(R.id.tab_new_msg_label)); final boolean needAdaptation = ScreenUtil.density <= 1.5 && screenAdaptation; final Resources resources = getContext().getResources(); if (titltTV != null) { titltTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_11) : resources.getDimensionPixelSize(R.dimen.text_size_15)); titltTV.setText(title); } if (unreadTV != null) { unreadTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_9) : resources.getDimensionPixelSize(R.dimen.text_size_12)); } addTab(position, tabView); }
From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java
private void addWarningTab(final int position, String title, int resId) { LinearLayout tabLayout = new LinearLayout(getContext()); tabLayout.setOrientation(LinearLayout.HORIZONTAL); tabLayout.setGravity(Gravity.CENTER); ImageView tabImg = new ImageView(getContext()); int width = DimenUtils.dp2px(getContext(), 18); LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(width, width); tabImgParams.setMargins(0, 0, DimenUtils.dp2px(getContext(), 10), 0); tabImgParams.gravity = Gravity.CENTER; tabImg.setLayoutParams(tabImgParams); if (resId != -1) { tabImg.setBackgroundResource(resId); tabImg.setVisibility(View.VISIBLE); } else {/*from w w w. j a v a 2s .c o m*/ tabImg.setVisibility(View.GONE); } tabLayout.addView(tabImg, 0); TextView tab = new TextView(getContext()); tab.setText(title); tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(getResources().getColorStateList( mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector)); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f); tabLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (null != mOnPageClickedLisener) { mOnPageClickedLisener.onPageClicked(position); } pager.setCurrentItem(position); } }); tabLayout.addView(tab, 1); tabsContainer.addView(tabLayout); }