List of usage examples for android.util TypedValue COMPLEX_UNIT_SP
int COMPLEX_UNIT_SP
To view the source code for android.util TypedValue COMPLEX_UNIT_SP.
Click Source Link
From source file:bruce.kk.brucetodos.MainActivity.java
/** * ???/* w w w . j av a2 s .c o m*/ * * @param position */ private void modifyItem(final int position) { final UnFinishItem item = dataList.get(position); LogDetails.d(item); LinearLayout linearLayout = new LinearLayout(MainActivity.this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearLayout.setLayoutParams(layoutParams); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setBackgroundColor(getResources().getColor(android.R.color.black)); final EditText editText = new EditText(MainActivity.this); editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); editText.setTextColor(getResources().getColor(android.R.color.holo_green_light)); editText.setHint(item.content); editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark)); linearLayout.addView(editText); Button btnModify = new Button(MainActivity.this); btnModify.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); btnModify.setText(""); btnModify.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); btnModify.setTextColor(getResources().getColor(android.R.color.holo_blue_bright)); btnModify.setBackgroundColor(getResources().getColor(android.R.color.black)); linearLayout.addView(btnModify); Button btnDeleteItem = new Button(MainActivity.this); btnDeleteItem.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); btnDeleteItem.setText(""); btnDeleteItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); btnDeleteItem.setTextColor(getResources().getColor(android.R.color.holo_blue_bright)); btnDeleteItem.setBackgroundColor(getResources().getColor(android.R.color.black)); linearLayout.addView(btnDeleteItem); final PopupWindow popupWindow = new PopupWindow(linearLayout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ? popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0); btnModify.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { LogDetails.d(": " + editText.getText().toString()); if (!TextUtils.isEmpty(editText.getText().toString().trim())) { Date date = new Date(); item.content = editText.getText().toString().trim(); item.modifyDay = date; item.finishDay = null; ProgressDialogUtils.showProgressDialog(); presenter.modifyItem(item); dataList.set(position, item); refreshData(true); popupWindow.dismiss(); } else { Toast.makeText(MainActivity.this, "~", Toast.LENGTH_SHORT).show(); } } }); btnDeleteItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dataList.remove(position); presenter.deleteItem(item); refreshData(false); popupWindow.dismiss(); } }); }
From source file:com.i2max.i2smartwork.common.conference.ConferenceDetailViewFragment.java
public void setFilesLayout(String title, LinearLayout targetLayout, Object object) { final List<LinkedTreeMap<String, String>> filesList = (List<LinkedTreeMap<String, String>>) object; if (filesList == null || (filesList != null && filesList.size() <= 0)) { targetLayout.setVisibility(View.GONE); } else {/*from ww w.ja va 2 s .c om*/ Log.e(TAG, "fileList size =" + filesList.size()); targetLayout.setVisibility(View.VISIBLE); targetLayout.removeAllViews(); //addTitleView LinearLayout.LayoutParams tvParam = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tvParam.setMargins(0, DisplayUtil.dip2px(getActivity(), 12), 0, DisplayUtil.dip2px(getActivity(), 10)); TextView tvTitle = new TextView(getActivity()); tvTitle.setLayoutParams(tvParam); if (Build.VERSION.SDK_INT < 23) { tvTitle.setTextAppearance(getActivity(), android.R.style.TextAppearance_Material_Medium); } else { tvTitle.setTextAppearance(android.R.style.TextAppearance_Material_Medium); } tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); tvTitle.setTextColor(getResources().getColor(R.color.text_color_black)); tvTitle.setText(title); targetLayout.addView(tvTitle); //addFilesView for (int i = 0; i < filesList.size(); i++) { final LinkedTreeMap<String, String> fileMap = filesList.get(i); LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View fileView = inflater.inflate(R.layout.view_item_file, null); ImageView ivIcFileExt = (ImageView) fileView.findViewById(R.id.iv_ic_file_ext); TextView tvFileNm = (TextView) fileView.findViewById(R.id.tv_file_nm); //?? ? ivIcFileExt.setImageResource(R.drawable.ic_file_doc); String fileNm = FormatUtil.getStringValidate(fileMap.get("file_nm")); tvFileNm.setText(fileNm); FileUtil.setFileExtIcon(ivIcFileExt, fileNm); final String fileExt = FileUtil.getFileExtsion(fileNm); final String downloadURL = I2UrlHelper.File .getDownloadFile(FormatUtil.getStringValidate(fileMap.get("file_id"))); fileView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent intent = null; if ("Y".equals(FormatUtil.getStringValidate(fileMap.get("conv_yn")))) { //i2viewer ? ( conv_yn='Y') intent = IntentUtil.getI2ViewerIntent( FormatUtil.getStringValidate(fileMap.get("file_id")), FormatUtil.getStringValidate(fileMap.get("file_nm"))); getActivity().startActivity(intent); } else if ("mp4".equalsIgnoreCase(fileExt) || "fla".equalsIgnoreCase(fileExt) || "wmv".equalsIgnoreCase(fileExt) || "avi".equalsIgnoreCase(fileExt)) { //video intent = IntentUtil.getVideoPlayIntent(downloadURL); } else { //? ?? intent = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadURL)); Bundle bundle = new Bundle(); bundle.putString("Authorization", I2UrlHelper.getTokenAuthorization()); intent.putExtra(Browser.EXTRA_HEADERS, bundle); Log.d(TAG, "intent:" + intent.toString()); } getActivity().startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), "I2Viewer? ? .\n ? ?.", Toast.LENGTH_LONG).show(); //TODO ? ? ? URL } } }); targetLayout.addView(fileView); } } }
From source file:com.justwayward.reader.view.RVPIndicator.java
/** * view//from w w w .j a v a 2 s. co m * * @param text * @return */ private TextView createTextView(String text) { TextView tv = new TextView(getContext()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); lp.width = getWidth() / mTabVisibleCount; tv.setGravity(Gravity.CENTER); tv.setTextColor(mTextColorNormal); tv.setText(text); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize); tv.setLayoutParams(lp); return tv; }
From source file:com.github.irshulx.Components.InputExtensions.java
private void addEditableStyling(TextView editText) { editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL)); editText.setFocusableInTouchMode(true); editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE); editText.setTextColor(Color.parseColor(this.DEFAULT_TEXT_COLOR)); editText.setPadding(0, 30, 0, 30);// ww w . jav a 2 s.c o m }
From source file:com.agenmate.lollipop.addedit.AddEditFragment.java
private void formatText(TextView textView, String string) { if (string != null) { textView.setText(MarkupUtils.fromHtml(string)); }//from ww w . ja v a 2s. c o m textView.setTextColor(Color.BLACK); textView.setTypeface(FontUtils.get(getActivity(), "Dudu")); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); }
From source file:cn.scujcc.bug.bitcoinplatformandroid.view.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab * view is not set via {@link #setCustomTabView(int, int)}. */// w w w . ja v a 2 s .c om protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setWidth(screenX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the // Theme's // selectableItemBackground to ensure that the View has a pressed // state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the // Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
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.//w w w.j a va 2s . 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.guerinet.materialtabs.TabLayout.java
/** * Creates a default view to be used for tabs. This is called if a custom tab view is not set * via {@link #setCustomTabView(int, int)}. * * @return The default view to use//w w w. j a v a2s . co m */ protected TextView createDefaultTabView() { TextView textView = new TextView(getContext()); prepareTextView(textView); textView.setGravity(Gravity.CENTER); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //Set the text color if there is one if (this.mDefaultTextColorId != null) { textView.setTextColor(getResources().getColor(mDefaultTextColorId)); } textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setBackgroundResource(getTabBackground()); //Padding int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.github.irshulx.Components.InputExtensions.java
private void updateTextStyle(TextView editText, EditorTextStyle editorTextStyle) { EditorControl tag;/*from w ww . j a va 2 s . co m*/ if (editText == null) { editText = (EditText) editorCore.getActiveView(); } EditorControl editorControl = editorCore.getControlTag(editText); if (isEditorTextStyleHeaders(editorTextStyle)) { if (editorCore.containsStyle(editorControl.editorTextStyles, editorTextStyle)) { editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE); editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL)); tag = reWriteTags(editorControl, EditorTextStyle.NORMAL); } else { editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextStyleFromStyle(editorTextStyle)); editText.setTypeface(getTypeface(HEADING, Typeface.BOLD)); tag = reWriteTags(editorControl, editorTextStyle); } editText.setTag(tag); } }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
/** * @return the font size measured in px/*from w w w . j a v a 2 s.co m*/ */ public int getFontSizeInPx() { DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mFontSize, metrics); }