List of usage examples for android.widget TextView setTypeface
public void setTypeface(@Nullable Typeface tf)
From source file:br.edu.ifpb.breath.slidingtabs.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, int)}. *//*from w ww .j a v a 2 s . co m*/ protected View createDefaultTabView(Context context, int type) { if (type == 0) { 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); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; } else { ImageView iconView = new ImageView(context); int iconSize = (int) (TAB_VIEW_ICON_SIZE_DIPS * getResources().getDisplayMetrics().density); int padding = (int) (TAB_VIEW_ICON_PADDING_DIPS * getResources().getDisplayMetrics().density); iconView.setLayoutParams(new LinearLayout.LayoutParams(iconSize + padding, iconSize + padding)); iconView.setScaleType(ImageView.ScaleType.FIT_CENTER); iconView.setPadding(padding, padding, padding, padding); return iconView; } }
From source file:cn.caimatou.canting.widget.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. jav a 2 s . c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); int textSize = (mTextSize <= 0 ? TAB_VIEW_TEXT_SIZE_SP : mTextSize); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); 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:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDayDeparturesFragment.java
@SuppressWarnings("deprecation") @Override/* w w w . j a va2 s. c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Typeface tfb = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Bold.ttf"); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_swipe_refresh, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorScheme(17170451, // android.R.color.holo_blue_bright 17170452, // android.R.color.holo_green_light 17170456, // android.R.color.holo_orange_light 17170454); // android.R.color.holo_red_light) mHeaderView = inflater.inflate(R.layout.list_item_departure_times_header, null); TextView departing_title = (TextView) mHeaderView.findViewById(R.id.departing_title); departing_title.setTypeface(tfb); TextView arriving_title = (TextView) mHeaderView.findViewById(R.id.arriving_title); arriving_title.setTypeface(tfb); mEmptyView = root.findViewById(R.id.empty_list_view); return root; }
From source file:com.googlecode.android_scripting.activity.Main.java
protected void initializeViews() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER_HORIZONTAL); TextView textview = new TextView(this); textview.setText(" PhpForAndroid " + version); ImageView imageView = new ImageView(this); imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa)); layout.addView(imageView);// w w w. ja va2 s . c o m mButton = new Button(this); mAboutButton = new Button(this); MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final float scale = getResources().getDisplayMetrics().density; int marginPixels = (int) (MARGIN_DIP * scale + 0.5f); marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels); mButton.setLayoutParams(marginParams); mAboutButton.setLayoutParams(marginParams); layout.addView(textview); layout.addView(mButton); layout.addView(mAboutButton); mProgressLayout = new LinearLayout(this); mProgressLayout.setOrientation(LinearLayout.HORIZONTAL); mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); LinearLayout bottom = new LinearLayout(this); bottom.setOrientation(LinearLayout.HORIZONTAL); bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.setGravity(Gravity.CENTER_VERTICAL); mProgressLayout.addView(bottom); TextView message = new TextView(this); message.setText(" In Progress..."); message.setTextSize(20); message.setTypeface(Typeface.DEFAULT_BOLD); message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); ProgressBar bar = new ProgressBar(this); bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.addView(bar); bottom.addView(message); mProgressLayout.setVisibility(View.INVISIBLE); layout.addView(mProgressLayout); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(false); setContentView(layout); }
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); } else {//from w w w .j ava 2s. c o m 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.example.chicharo.clean_ambar.util.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 ww . ja v a2 s. c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); // 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, //Ripple effect 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.androprogrammer.tutorials.customviews.SlidingTabLayout.java
protected TextView createDefaultTextTabView(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) { // 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); }/*from w ww.j a v a2 s . co m*/ 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); //System.out.println("c " + titleColor); if (titleColor != null) { textView.setTextColor(titleColor); } return textView; }
From source file:com.edaviessmith.consumecontent.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 w w w . j av a 2 s . c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setTextSize(18); textView.setTextColor(getContext().getResources().getColor(android.R.color.white)); 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.bryan.example.widget.slidingtablayout.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 va2 s . c o m @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { /** * ?Holo?? */ 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.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); return textView; }
From source file:com.geomoby.geodeals.DemoService.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.geomoby_main); mContext = this; mToggle = (CompoundButton) findViewById(R.id.togglebutton); spref = getSharedPreferences(PREF_NAME, MODE_PRIVATE); isCheckedStatus = spref.getBoolean("check", false); //default is false /*//from w w w . java 2s .com * Set up toggle status */ if (!isCheckedStatus) mToggle.setChecked(false); else mToggle.setChecked(true); /* * Save the tags in the GeoMoby shared preferences in private mode for the user. These tags will be used * to segment your audience when creating your proximity alerts. Please make sure that they match with * the ones configured in your dashboard when you create an alert. * Ex: 'test' is the default tag so make sure that it is set up in your Account page */ SharedPreferences mySharedPreferences = getSharedPreferences(PREF, MODE_PRIVATE); // Build the string of tags - empty for testing. Make sure that you create your first geofences with no tags in your dashboard. // Add your own logic here: "male,vip,monday"... String tags = ""; // Commit the string SharedPreferences.Editor prefEditor = mySharedPreferences.edit(); prefEditor.putString(SETTING_TAGS, tags); prefEditor.commit(); /* * Monitor the toggle - Our SDK will ensure that all services are running/stopping properly */ mToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked == false) { mToggle.setPressed(false); // Stop the GeoMoby tracking service startService(new Intent(DemoService.this, GeomobyStopService.class)); SharedPreferences.Editor editor = spref.edit(); editor.putBoolean("check", false); editor.commit(); } else { mToggle.setPressed(true); // Start the GeoMoby tracking service startService(new Intent(DemoService.this, GeomobyStartService.class)); SharedPreferences.Editor editor = spref.edit(); editor.putBoolean("check", true); editor.commit(); LayoutInflater inflater = getLayoutInflater(); // Inflate the Layout View layout = inflater.inflate(R.layout.geomoby_toast, (ViewGroup) findViewById(R.id.custom_toast_layout)); // Set the Text to show in TextView TextView text = (TextView) layout.findViewById(R.id.textToShow); text.setText("GREAT! YOU ARE READY TO RECEIVE REAL-TIME NOTIFICATIONS!"); Typeface face; face = Typeface.createFromAsset(getAssets(), "Bitter-Bold.otf"); text.setTypeface(face); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.BOTTOM, 0, 50); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); } } }); // Initialise GeoMoby Notification Listener GeomobyNotificationsReceiver receiver = new GeomobyNotificationsReceiver(); receiver.setNotificationListener(this); }