List of usage examples for android.widget TextView setTypeface
public void setTypeface(@Nullable Typeface tf)
From source file:com.cookbeans.boredapp.ui.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)}.//from ww w .j ava 2s .c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.WHITE); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); // textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTypeface(Typeface.DEFAULT); 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); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f); textView.setLayoutParams(layoutParams); return textView; }
From source file:com.example.reabar.wimc.Fragments.MySharedCarsScreenFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_my_shared_cars_screen, container, false); TextView title = (TextView) view.findViewById(R.id.logoText); TextView text = (TextView) view.findViewById(R.id.textTextView); 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("")) { title.setTypeface(hebrew); text.setTypeface(hebrew);// ww w .j a va 2 s . c o m } else { title.setTypeface(english); text.setTypeface(english); } if (cars == null) { cars = new ArrayList<>(); } progressBar = (ProgressBar) view.findViewById(R.id.mySharedCars_ProgressBar); progressBar.setVisibility(View.VISIBLE); carsList = (ListView) view.findViewById(R.id.listShredCars); Model.getInstance().getListOfSharedCars(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) { } }); adapter = new MySharedCarsAdapter(); carsList.setAdapter(adapter); /* carsList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(MyApplication.getAppActivity(), "Row Clicked!", Toast.LENGTH_SHORT).show(); } });*/ return view; }
From source file:com.do_an_httt.truon_000.jobssocialnetwork.view.SlidingTabLayoutEmployeeUpdate.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 ww . jav a2 s . co m*/ */ protected TextView createDefaultTabView(Context context) { int width_device = getResources().getDisplayMetrics().widthPixels; TextView textView = new TextView(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(width_device / 2, ViewGroup.LayoutParams.MATCH_PARENT); textView.setLayoutParams(params); 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) { // 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:com.example.abner.dynamicfragment.view.CustomSlidingTabLayout.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)}./*from w w w.j av a2s. c om*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(dTextColor); // mTextSize is sp textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); if (mNeedBold) { textView.setTypeface(Typeface.DEFAULT_BOLD); } 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); if (mShouldExpand) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.width = 0; layoutParams.weight = 1; textView.setLayoutParams(layoutParams); } return textView; }
From source file:com.do_an_httt.truon_000.jobssocialnetwork.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 . j av a 2 s . co m */ protected TextView createDefaultTabView(Context context) { int width_device = getResources().getDisplayMetrics().widthPixels; TextView textView = new TextView(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(width_device / 3, ViewGroup.LayoutParams.MATCH_PARENT); textView.setLayoutParams(params); 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) { // 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:com.fsa.en.dron.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RateThisApp.Config config = new RateThisApp.Config(5, 10); config.setTitle(R.string.my_own_title); config.setMessage(R.string.my_own_message); config.setYesButtonText(R.string.my_own_rate); config.setNoButtonText(R.string.my_own_thanks); config.setCancelButtonText(R.string.my_own_cancel); RateThisApp.init(config);/*from www. ja va2s . c o m*/ RateThisApp.setCallback(new RateThisApp.Callback() { @Override public void onYesClicked() { final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } } @Override public void onNoClicked() { TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG, TastyToast.INFO); } @Override public void onCancelClicked() { TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!", TastyToast.LENGTH_LONG, TastyToast.ERROR); } }); button = (Button) findViewById(R.id.button); button.setVisibility(View.INVISIBLE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkConnection(); } }); BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar); bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE); bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED); bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC); bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800); bottomNavigationBar.setActiveColor(R.color.material_grey_900); bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200); bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje")) .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales")) .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise(); bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() { @Override public void onTabSelected(int position) { switch (position) { case 0: Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" }); email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron"); email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje"); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, "Elige un cliente :")); break; case 1: Intent intent = new Intent(getApplication(), FacebookActivity.class); startActivity(intent); break; case 2: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.fsa.en.dron"); startActivity(Intent.createChooser(sharingIntent, "Compartir via")); break; } } @Override public void onTabUnselected(int position) { } @Override public void onTabReselected(int position) { switch (position) { case 0: break; case 1: Intent intent = new Intent(getApplication(), FacebookActivity.class); startActivity(intent); break; case 2: break; } } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); LayoutInflater inflator = LayoutInflater.from(this); View v = inflator.inflate(R.layout.toolbar_title, null); Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf"); Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf"); TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title); TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle); mToolbarCustomTitle.setText("Formosa"); mToolbarCustomSubTitle.setText("en dron"); mToolbarCustomTitle.setTypeface(typographica); mToolbarCustomSubTitle.setTypeface(budget); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int id = item.getItemId(); if (id == R.id.recargar) { checkConnection(); } if (id == R.id.info) { showDialog(); } return false; } }); recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(), recyclerView, new GalleryAdapter.ClickListener() { @Override public void onClick(View view, int position) { Bundle bundle = new Bundle(); bundle.putSerializable("images", images); bundle.putInt("position", position); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance(); newFragment.setArguments(bundle); newFragment.show(ft, "slideshow"); } @Override public void onLongClick(View view, int position) { } })); pDialog = new ProgressDialog(this); images = new ArrayList<>(); mAdapter = new GalleryAdapter(getApplicationContext(), images); RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(mAdapter); }
From source file:com.honeywell.printer.indicator.TabPageIndicator.java
/** * ?/*from w w w . ja v a 2s .c o m*/ * * @param index tab * @param count ? */ public void showTabMsgCountView(int index, int count, int res) { if (mTabLayout != null) { final TextView msgCountView = (TextView) mTabLayout.findViewById(index + ID_OFFSET); if (msgCountView != null) { final int color = getResources().getColor(R.color.new_msg_num_text_color); msgCountView.setTextColor(color); msgCountView.setGravity(Gravity.CENTER); msgCountView.setTypeface(Typeface.DEFAULT_BOLD); // final int paddingPixels = Tools.dp2px(2); int paddingPixels = (int) getResources().getDimension(R.dimen.indicator_num_padding); msgCountView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final int badgeMarginLeft = (int) getResources().getDimension(R.dimen.indicator_marginleft); final int badgeMarginBottom = (int) getResources().getDimension(R.dimen.indicator_marginbottom); params.gravity = Gravity.CENTER; params.setMargins(badgeMarginLeft, 0, 0, badgeMarginBottom); if (count == 0) { msgCountView.setVisibility(View.GONE); return; } else if (count > 99) { msgCountView.setText("99+"); msgCountView.setBackgroundResource(R.drawable.tab_msg_num_big_bg); } else { msgCountView.setText(String.valueOf(count)); msgCountView.setBackgroundResource(res); } msgCountView.setTextSize(11); msgCountView.setLayoutParams(params); msgCountView.setVisibility(View.VISIBLE); } } }
From source file:com.andreapivetta.blu.fragments.tabs.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 ww .j a v a 2 s. c o m */ 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 / 2); 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); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); textView.setTextColor(getResources().getColor(com.andreapivetta.blu.R.color.white)); return textView; }
From source file:com.andreapivetta.changemywall.tabs.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 a va 2s. c o m*/ */ 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 / 3); 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); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
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)}./*from w w w. j ava2 s . 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; }