List of usage examples for android.widget TextView setTextSize
public void setTextSize(int unit, float size)
From source file:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java
@Override public Object instantiateItem(View collection, int position) { // Create the "Step N of T" TextView TextView stepTextView = new TextView(this.context); stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); stepTextView.setTextColor(Color.rgb(113, 113, 113)); stepTextView.setGravity(Gravity.CENTER); stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1, this.solution.size())); // Create the boar with the current step of the solution BoardCanvas board = new BoardCanvas(this.context); board.setBoardRepresentation(this.solution.get(position).getBoard()); board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(), this.solution.get(position).getDirection()); // Add the components to the layout LinearLayout layout = new LinearLayout(this.context); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(16, 20, 16, 16);/*from ww w . ja v a2 s . c o m*/ RelativeLayout relativeLatout = new RelativeLayout(this.context); relativeLatout.setLayoutParams( new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); relativeLatout.addView(board); layout.addView(relativeLatout); layout.addView(stepTextView); ((ViewPager) collection).addView(layout, 0); return layout; }
From source file:com.ruenzuo.through.activities.LicensesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.licenses_activity_layout); getActionBar().setDisplayHomeAsUpEnabled(true); AssetManager assetManager = getAssets(); try {/* w w w . j a v a2 s . co m*/ InputStream inputStream = assetManager.open("licenses/licenses.txt"); StringWriter stringWriter = new StringWriter(); IOUtils.copy(inputStream, stringWriter); String licenses = stringWriter.toString(); TextView txtViewLicenses = (TextView) findViewById(R.id.txtViewLicenses); txtViewLicenses.setText(licenses); txtViewLicenses.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.ruenzuo.pokeffective.activities.InfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.info_activity); getActionBar().setDisplayHomeAsUpEnabled(true); Uri data = getIntent().getData();/* w w w . ja v a 2s . co m*/ if (data != null) { getActionBar().setTitle("License"); AssetManager assetManager = getAssets(); try { InputStream inputStream = assetManager.open("licenses/licenses.txt"); StringWriter stringWriter = new StringWriter(); IOUtils.copy(inputStream, stringWriter); String licenses = stringWriter.toString(); TextView txtViewLicenses = (TextView) findViewById(R.id.txtViewLicenses); txtViewLicenses.setText(licenses); txtViewLicenses.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); } catch (IOException e) { e.printStackTrace(); } } }
From source file:am.project.x.business.widgets.gradienttabstrip.GradientTabStripActivity.java
private ArrayList<View> getPagers() { ArrayList<View> views = new ArrayList<>(); for (int i = 0; i < 4; i++) { TextView text = new TextView(this); text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180); text.setText(String.format(Locale.getDefault(), "%d", i + 1)); text.setGravity(Gravity.CENTER); text.setTextColor(0xff000000);/* w w w. ja v a 2 s . c o m*/ views.add(text); } return views; }
From source file:ch.pantas.billsplitter.ui.FixedTabsView.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { TextView v = (TextView) tabsContainer.getChildAt(i); TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor);/*from ww w . j a v a 2s . c o m*/ tab.setAllCaps(textAllCaps); } }
From source file:cat.ereza.customactivityoncrash.activity.DefaultErrorReportActivity.java
@SuppressLint("PrivateResource") @Override/* www .ja va 2s .co m*/ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); //This is needed to avoid a crash if the developer has not specified //an app-level theme that extends Theme.AppCompat TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme); if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) { setTheme(R.style.Theme_AppCompat_Light_DarkActionBar); } a.recycle(); setContentView(R.layout.customactivityoncrash_default_error_activity); //Close/restart button logic: //If a class if set, use restart. //Else, use close and just finish the app. //It is recommended that you follow this logic if implementing a custom error activity. Button restartButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_restart_button); final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent()); if (config.isShowRestartButton() && config.getRestartActivityClass() != null) { restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app); restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.restartApplication(DefaultErrorReportActivity.this, config); } }); } else { restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.closeApplication(DefaultErrorReportActivity.this, config); } }); } Button moreInfoButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_more_info_button); if (config.isShowErrorDetails()) { moreInfoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //We retrieve all the error data and show it AlertDialog dialog = new AlertDialog.Builder(DefaultErrorReportActivity.this) .setTitle(R.string.customactivityoncrash_error_activity_error_details_title) .setMessage(CustomActivityOnCrash .getAllErrorDetailsFromIntent(DefaultErrorReportActivity.this, getIntent())) .setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null) .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { copyErrorToClipboard(); Toast.makeText(DefaultErrorReportActivity.this, R.string.customactivityoncrash_error_activity_error_details_copied, Toast.LENGTH_SHORT).show(); } }) .show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size)); } }); } else { moreInfoButton.setVisibility(View.GONE); } Integer defaultErrorActivityDrawableId = config.getErrorDrawable(); ImageView errorImageView = ((ImageView) findViewById(R.id.customactivityoncrash_error_activity_image)); if (defaultErrorActivityDrawableId != null) { errorImageView.setImageDrawable( ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme())); } }
From source file:br.com.frs.foodrestrictions.FoodMessages.java
@SuppressLint("SetTextI18n") private void refreshMessages(View v) { int nAllergic = 0; int nDontEat = 0; llAllergic.removeAllViews();// w w w .jav a 2s.c om llDontEat.removeAllViews(); for (final FoodIconItem iconItem : restrictList) { final String foodName = getResources().getString(iconItem.getNameId()); final String allergic_text = getResources().getString(R.string.allergic_to) + " " + foodName; final String dont_eat_text = getResources().getString(R.string.dont_eat) + " " + foodName; TextView tv = new TextView(v.getContext()); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tv.setTypeface(null, Typeface.BOLD_ITALIC); tv.setText("* " + foodName); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (iconItem.getRestrictionType()) { case FoodIconList.FOOD_RESTRICTION_TYPE_ALLERGIC: Snackbar.make(v, allergic_text, Snackbar.LENGTH_LONG).setAction("Action", null).show(); break; case FoodIconList.FOOD_RESTRICTION_TYPE_DONT_EAT: Snackbar.make(v, dont_eat_text, Snackbar.LENGTH_LONG).setAction("Action", null).show(); break; } } }); if (iconItem.getRestrictionType() == FoodIconList.FOOD_RESTRICTION_TYPE_ALLERGIC) { llAllergic.addView(tv); ++nAllergic; } else { llDontEat.addView(tv); ++nDontEat; } } if (nAllergic == 0) { allergicText.setVisibility(View.GONE); TextView tv = new TextView(v.getContext()); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tv.setTypeface(null, Typeface.BOLD_ITALIC); tv.setText("* " + getResources().getString(R.string.food_msg_not_allergic)); llAllergic.addView(tv); } else { allergicText.setText(getResources().getString(R.string.message_allergic_to)); } if (nDontEat == 0) { dontEatText.setVisibility(View.GONE); TextView tv = new TextView(v.getContext()); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tv.setTypeface(null, Typeface.BOLD_ITALIC); tv.setText("* " + getResources().getString(R.string.food_msg_not_picker)); llDontEat.addView(tv); } else { dontEatText.setText(getResources().getString(R.string.message_dont_eat)); } }
From source file:at.wada811.android.dialogfragments.sample.dialogfragmentcallbackprovider.DialogFragmentCallbackProviderFragment.java
@Override public DialogFragmentCallback getDialogFragmentCallback() { return new SimpleDialogFragmentCallback() { @Override//w w w .j av a 2 s. co m public View getView(DialogFragmentInterface dialog) { TextView titleView = new TextView(getActivity()); titleView.setText("Use getChildFragmentManager()"); titleView.setPadding(0, 24, 0, 24); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); return titleView; } }; }
From source file:com.acrylicgoat.houstonbicyclemuseum.view.SlidingTabLayout.java
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); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }//from w w w . jav a 2 s . c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.bruno.distribuciones.android.SlidingTabLayout.java
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.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true);//from w w w . j a va2 s .c o m int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }