List of usage examples for android.widget TextView setTextSize
@android.view.RemotableViewMethod public void setTextSize(float size)
From source file:com.example.francis.examinationsystem.view.thirty.SlidingTabLayout.java
private void updateSelectedTitle(int positon) { final PagerAdapter adapter = mViewPager.getAdapter(); for (int i = 0; i < adapter.getCount(); ++i) { final View tabView = mTabStrip.getChildAt(i); if (TextView.class.isInstance(tabView)) { TextView titleView = (TextView) tabView; titleView.getPaint().setFakeBoldText(true); boolean isSelected = i == positon; titleView.setTextColor(isSelected ? getResources().getColor(android.R.color.white) : getResources().getColor(R.color.colorNormalText)); titleView.setTextSize(isSelected ? 20 : TAB_VIEW_TEXT_SIZE_SP); }//from ww w .j av a 2s . c o m } }
From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.detail_help) { Intent detailIntent = new Intent(getActivity(), HelpActivity.class); startActivity(detailIntent);//from w ww . j a v a 2s . c o m } else if (id == R.id.qr_code) { try { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); // "PRODUCT_MODE for bar codes startActivityForResult(intent, 0); } catch (Exception e) { // This is where the play store is called if the app is not installed Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); startActivity(marketIntent); } } else if (id == R.id.save) { InetAddressValidator ipValidate = new InetAddressValidator(); Context context = getActivity(); // We know we will use a toast, so set it up now int duration = Toast.LENGTH_LONG; CharSequence text = "Saving config"; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastLayout = (LinearLayout) toast.getView(); TextView toastTV = (TextView) toastLayout.getChildAt(0); toastTV.setTextSize(30); //The following is all input validation try { if ((Integer.parseInt(txt_server_port.getText().toString()) > 0) && (Integer.parseInt(txt_server_port.getText().toString()) < 65535)) { // check for valid port txt_server_port.setText(String.valueOf(Integer.parseInt(txt_server_port.getText().toString()))); } else { txt_server_port.setText(String.valueOf(62201)); } } catch (NumberFormatException ex) { txt_server_port.setText(String.valueOf(62201)); } if (txt_NickName.getText().toString().equalsIgnoreCase("")) { // Need to create a new Nick toast.setText("You Must choose a unique Nickname."); // choosing a used nick will just overwrite it. So really toast.show(); } else if (chkb64hmac.isChecked() && txt_HMAC.getText().toString().length() % 4 != 0) { // base64 must have a multiple of 4 length toast.setText("Hmac is not a valid Base64, not a multiple of 4."); toast.show(); } else if (chkb64hmac.isChecked() && !(txt_HMAC.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters toast.setText("Hmac is not a valid Base64, Contains disallowed characters."); toast.show(); } else if (chkb64key.isChecked() && txt_KEY.getText().toString().length() % 4 != 0) { toast.setText("Key is not a valid Base64, not a multiple of 4."); toast.show(); } else if (chkb64key.isChecked() && !(txt_KEY.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters toast.setText("Key is not a valid Base64, Contains disallowed characters."); toast.show(); } else if (!(txt_ports.getText().toString().matches("tcp/\\d.*") || txt_ports.getText().toString().matches("udp/\\d.*"))) { toast.setText("Access ports must be in the form of 'tcp/22'"); toast.show(); } else if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Allow IP") && (!ipValidate.isValid(txt_allowIP.getText().toString()))) { //Have to have a valid ip to allow, if using allow ip toast.setText("You Must supply a valid IP address to 'Allow IP'."); toast.show(); } else if (!ipValidate.isValid(txt_server_ip.getText().toString()) && !DomainValidator.getInstance().isValid(txt_server_ip.getText().toString())) { // check server entry. Must be a valid url or ip. toast.setText("You Must supply a valid server address."); toast.show(); } else if (txt_KEY.getText().toString().equalsIgnoreCase("")) { toast.setText("You Must supply a Rijndael key."); toast.show(); } else if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("Juicessh") && juice_adapt.getConnectionName(spn_juice.getSelectedItemPosition()) == null) { toast.setText("A connection must be saved in Juicessh before being used here."); toast.show(); // //end input validation, actual saving below } else { toast.show(); if (configtype.equalsIgnoreCase("Open Port")) { config.PORTS = txt_ports.getText().toString(); config.SERVER_TIMEOUT = txt_server_time.getText().toString(); } else { config.PORTS = ""; config.SERVER_TIMEOUT = ""; } if (configtype.equalsIgnoreCase("Nat Access")) { config.NAT_IP = txt_nat_ip.getText().toString(); config.NAT_PORT = txt_nat_port.getText().toString(); config.PORTS = txt_ports.getText().toString(); config.SERVER_TIMEOUT = txt_server_time.getText().toString(); } else { config.NAT_IP = ""; config.NAT_PORT = ""; } if (configtype.equalsIgnoreCase("Server Command")) { config.SERVER_CMD = txt_server_cmd.getText().toString(); } else { config.SERVER_CMD = ""; } if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Resolve IP")) { config.ACCESS_IP = spn_allowip.getSelectedItem().toString(); } else if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Source IP")) { config.ACCESS_IP = "0.0.0.0"; } else { config.ACCESS_IP = txt_allowIP.getText().toString(); } config.NICK_NAME = txt_NickName.getText().toString(); config.SERVER_IP = txt_server_ip.getText().toString(); config.SERVER_PORT = txt_server_port.getText().toString(); config.SSH_CMD = ""; if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("SSH Uri")) { config.SSH_CMD = txt_ssh_cmd.getText().toString(); config.juice_uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); } else if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("Juicessh")) { config.SSH_CMD = "juice:" + juice_adapt.getConnectionName(spn_juice.getSelectedItemPosition()); config.juice_uuid = juice_adapt.getConnectionId(spn_juice.getSelectedItemPosition()); } else { config.juice_uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); config.SSH_CMD = ""; } config.KEY = txt_KEY.getText().toString(); //key config.KEY_BASE64 = chkb64key.isChecked(); //is key b64 config.HMAC = txt_HMAC.getText().toString(); // hmac key config.HMAC_BASE64 = chkb64hmac.isChecked(); //is hmac base64 mydb.updateConfig(context, config); //this updates the list for one panel mode Activity activity = getActivity(); if (activity instanceof ConfigListActivity) { ConfigListActivity myactivity = (ConfigListActivity) activity; myactivity.onItemSaved(); } else { ConfigDetailActivity myactivity = (ConfigDetailActivity) activity; myactivity.onBackPressed(); } } } else { return false; } return super.onOptionsItemSelected(item); }
From source file:com.cssweb.android.quote.QHSCGridActivity.java
private void AddViewItem(int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f); localTextView.setGravity(Gravity.CENTER); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); // touch localTextView.setTag(paramInt2);//from w w w . j a v a2 s. c o m localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(true); Resources localResources = getResources(); Drawable localDrawable = null; if (paramInt4 == 0 && paramInt3 >= 0) {// int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = localResources.getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = localResources.getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 13) { localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 % 2 == 0) { localDrawable = localResources.getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = localResources.getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = localResources.getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 13) { localDrawable = localResources.getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 % 2 == 0) { localDrawable = localResources.getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = localResources.getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } }
From source file:com.dtd.thevyshka.Utils.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 . j ava2s . c o m*/ */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mTabCount); textView.setGravity(Gravity.CENTER); textView.setTextSize(12);//TODO adapting to all textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(ContextCompat.getColor(context, R.color.white)); 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 / 2, padding, padding / 2, padding); return textView; }
From source file:com.example.reabar.wimc.Fragments.HomeScreenFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_home_screen, container, false); TextView hello = (TextView) view.findViewById(R.id.helloTextView); Typeface english = Typeface.createFromAsset(getActivity().getAssets(), "KOMIKAX_.ttf"); // create a typeface from the raw ttf Typeface hebrew = Typeface.createFromAsset(getActivity().getAssets(), "OpenSansHebrew-Bold.ttf"); // create a typeface from the raw ttf if (Locale.getDefault().getDisplayLanguage().equals("")) { hello.setTypeface(hebrew);/* ww w . j a v a 2s. com*/ } else { hello.setTypeface(english); hello.setTextSize(26); } progressBar = (ProgressBar) view.findViewById(R.id.homepageProgressBar); progressBar.setVisibility(View.VISIBLE); if (Model.getInstance().getCurrentUser() != null) { Model.getInstance().getMyUnparkedCars(Model.getInstance().getCurrentUser().getEmail(), new Model.SyncListener() { @Override public void passData(Object allCars) { cars = (ArrayList) allCars; progressBar.setVisibility(View.GONE); adapter.notifyDataSetChanged(); } @Override public void isSuccessful(boolean s) { } @Override public void failed(String s) { } }); } carsList = (ListView) view.findViewById(R.id.listCarsNotParkingNow); adapter = new CarsNotParkingAdapter(); carsList.setAdapter(adapter); carsList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Object[] data = new Object[1]; data[0] = cars.get(position).getCarId(); fragmentCommunicator.passData(data, "ParkingScreenFragment"); } }); return view; }
From source file:com.altitudelabs.swiftcart.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from ww w . j a v a 2 s. c o m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextSize(getResources().getDimension(R.dimen.pager_tab_strip_slider_textsize)); tab.setTextColor(getResources().getColor(R.color.pager_tab_strip_text_color)); addTab(position, tab); }
From source file:com.adarshahd.indianrailinfo.donate.TrainEnquiry.java
private void startDetailsActivity() { //For testing!!! /*File file = new File("/sdcard/train_details_trn_number.html"); String result = "";/*from w w w . j a va2s .c om*/ try { FileInputStream stream = new FileInputStream(file); InputStreamReader readerStream = new InputStreamReader(stream); BufferedReader reader = new BufferedReader(readerStream); String str; while((str = reader.readLine()) != null) { result += str; } } catch (IOException e) { e.printStackTrace(); }*/ if (mPage.contains("unavailable")) { TextView tv = new TextView(mActivity); tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL)); tv.setTextColor(Color.RED); tv.setTextSize(20); tv.setText( "Response from server: \n\n\"The requested service is currently unavailable. Please try again later\""); mFrameLayout.removeAllViews(); mFrameLayout.addView(tv); return; } if (mPage.contains("invalid")) { TextView tv = new TextView(mActivity); tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL)); tv.setTextColor(Color.RED); tv.setTextSize(20); tv.setText("Invalid Station code! Please select the station code from drop down list."); mFrameLayout.removeAllViews(); mFrameLayout.addView(tv); return; } if (mPage.contains("No Matching Trains")) { TextView tv = new TextView(mActivity); tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL)); tv.setTextColor(Color.RED); tv.setTextSize(20); tv.setText("No Matching train found! Please check the train number/name"); mFrameLayout.removeAllViews(); mFrameLayout.addView(tv); return; } //put the required intent data and start TrainEnquiryDetails activity. Intent intent = new Intent(this, TrainEnquiryDetails.class); intent.putExtra(TRAIN, mTrainNumber); intent.putExtra(SEARCH, searchUsingTrnNumber); intent.putExtra(PAGE, mPage); intent.putExtra(SRC, mACTFrom.getText().toString()); intent.putExtra(DST, mACTTo.getText().toString()); intent.putExtra(DAY_TRAVEL, mCal.get(Calendar.DAY_OF_MONTH)); intent.putExtra(MONTH_TRAVEL, mCal.get(Calendar.MONTH)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //Try to parse the mTrainNumber; try { Integer.parseInt(mTrainNumber); isInteger = true; } catch (Exception e) { isInteger = false; } intent.putExtra(ISINT, isInteger); startActivity(intent); }
From source file:com.example.linkagescroll.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setTextSize(14); tab.setText(title);/*from www . j a va 2s . co m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.todoroo.astrid.notes.EditNoteActivity.java
private void setUpInterface() { timerView = commentsBar.findViewById(R.id.timer_container); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); final boolean showTimerShortcut = preferences.getBoolean(R.string.p_show_timer_shortcut, false); if (showTimerShortcut) { commentField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override// ww w . java 2s .c o m public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { timerView.setVisibility(View.GONE); commentButton.setVisibility(View.VISIBLE); } else { timerView.setVisibility(View.VISIBLE); commentButton.setVisibility(View.GONE); } } }); } commentField.setHorizontallyScrolling(false); commentField.setMaxLines(Integer.MAX_VALUE); commentField.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { AndroidUtilities.hideSoftInputForViews(activity, commentField); return true; } return false; } }); commentField.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { commentField.setCursorVisible(true); } }); commentField.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { commentButton.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE : View.GONE); if (showTimerShortcut) { timerView.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.GONE : View.VISIBLE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // } }); commentField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (commentField.getText().length() > 0) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) { // commentField.setCursorVisible(false); addComment(); } } return false; } }); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addComment(); } }); final ClearImageCallback clearImage = new ClearImageCallback() { @Override public void clearImage() { pendingCommentPicture = null; pictureButton.setImageResource(cameraButton); } }; pictureButton = (ImageButton) commentsBar.findViewById(R.id.picture); pictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pendingCommentPicture != null) { actFmCameraModule.showPictureLauncher(clearImage); } else { actFmCameraModule.showPictureLauncher(null); } respondToPicture = true; } }); if (!TextUtils.isEmpty(task.getNotes())) { TextView notes = new TextView(getContext()); notes.setLinkTextColor(Color.rgb(100, 160, 255)); notes.setTextSize(18); notes.setText(task.getNotes()); notes.setPadding(5, 10, 5, 10); Linkify.addLinks(notes, Linkify.ALL); } if (activity != null) { String uri = activity.getIntent().getStringExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS); if (uri != null) { pendingCommentPicture = Uri.parse(uri); setPictureButtonToPendingPicture(); } } }
From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java
@Override protected void onFinishInflate() { super.onFinishInflate(); if (mLeftViewId != 0 && mSwipeLeftHorizontal == null) { View view = findViewById(mLeftViewId); mSwipeLeftHorizontal = new SwipeLeftHorizontal(view); }//from w w w. jav a2 s . co m if (mRightViewId != 0 && mSwipeRightHorizontal == null) { View view = findViewById(mRightViewId); mSwipeRightHorizontal = new SwipeRightHorizontal(view); } if (mContentViewId != 0 && mContentView == null) { mContentView = findViewById(mContentViewId); } else { TextView errorView = new TextView(getContext()); errorView.setClickable(true); errorView.setGravity(Gravity.CENTER); errorView.setTextSize(16); errorView.setText("You may not have set the ContentView."); mContentView = errorView; addView(mContentView); } }