Example usage for android.widget TextView setTypeface

List of usage examples for android.widget TextView setTypeface

Introduction

In this page you can find the example usage for android.widget TextView setTypeface.

Prototype

public void setTypeface(@Nullable Typeface tf, @Typeface.Style int style) 

Source Link

Document

Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.

Usage

From source file:com.guipenedo.pokeradar.activities.MapsActivity.java

/**
 * Manipulates the map once available.//  ww  w  . ja v  a 2s .  c o m
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMyLocationEnabled(true);
    mMap.getUiSettings().setMyLocationButtonEnabled(true);
    mMap.getUiSettings().setZoomControlsEnabled(true);
    mMap.setOnMapLongClickListener(this);
    mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
        @Override
        public boolean onMyLocationButtonClick() {
            onConnected(null);
            update();
            return true;
        }
    });
    mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
        @Override
        public void onInfoWindowClick(Marker m) {
            PMarker marker = pokemonMarkers.get(m.getId());
            if (marker == null || marker.type != PMarker.MarkerType.GYM)
                return;
            Intent gymIntent = new Intent(MapsActivity.this, GymDetailsActivity.class);
            gymIntent.putExtra("gymDetails", (PGym) marker);
            startActivity(gymIntent);
        }
    });
    mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) {
            return null;
        }

        @Override
        public View getInfoContents(final Marker m) {

            Context mContext = MapsActivity.this;

            LinearLayout info = new LinearLayout(mContext);
            info.setOrientation(LinearLayout.VERTICAL);

            TextView title = new TextView(mContext);
            title.setText(m.getTitle());
            title.setTypeface(null, Typeface.BOLD);
            title.setGravity(Gravity.CENTER);
            info.addView(title);

            final PMarker marker = pokemonMarkers.get(m.getId());
            long timestamp = -1;
            if (marker != null) {
                if (marker.type == PMarker.MarkerType.CENTER) {
                    TextView littleNotice = new TextView(mContext);
                    littleNotice.setText(R.string.scan_center_infowindow);
                    littleNotice.setGravity(Gravity.CENTER);
                    info.addView(littleNotice);
                } else if (marker.type == PMarker.MarkerType.LUREDPOKESTOP) {
                    PPokestop pokestopMarker = (PPokestop) marker;
                    timestamp = pokestopMarker.getTimestamp();
                    TextView remainingTime = new TextView(mContext);
                    String text = String.format(getString(R.string.lured_remaining), Utils.countdownFromMillis(
                            mContext, pokestopMarker.getTimestamp() - System.currentTimeMillis()));
                    remainingTime.setText(text);
                    remainingTime.setGravity(Gravity.CENTER);
                    info.addView(remainingTime);
                    TextView expireTime = new TextView(mContext);
                    expireTime.setText(Utils.timeFromMillis(pokestopMarker.getTimestamp()));
                    expireTime.setGravity(Gravity.CENTER);
                    info.addView(expireTime);
                } else if (marker.type == PMarker.MarkerType.GYM) {
                    PGym gymMarker = (PGym) marker;
                    Team team = Team.fromTeamColor(gymMarker.getTeam());
                    TextView teamName = new TextView(mContext);
                    teamName.setText(team.getName());
                    teamName.setTextColor(team.getColor());
                    teamName.setGravity(Gravity.CENTER);
                    info.addView(teamName);
                    TextView prestige = new TextView(mContext);
                    prestige.setText(String.format(getString(R.string.gym_points), gymMarker.getPoints()));
                    prestige.setGravity(Gravity.CENTER);
                    info.addView(prestige);
                    TextView clickDetails = new TextView(mContext);
                    clickDetails.setText(R.string.gym_details);
                    clickDetails.setTypeface(null, Typeface.BOLD);
                    clickDetails.setGravity(Gravity.CENTER);
                    info.addView(clickDetails);
                } else if (marker.type == PMarker.MarkerType.POKEMON) {
                    PPokemon pokemonMarker = (PPokemon) marker;
                    timestamp = pokemonMarker.getTimestamp();
                    final TextView remainingTime = new TextView(mContext);
                    remainingTime.setText(
                            String.format(getString(R.string.pokemon_despawns_time), Utils.countdownFromMillis(
                                    mContext, pokemonMarker.getTimestamp() - System.currentTimeMillis())));
                    remainingTime.setGravity(Gravity.CENTER);
                    info.addView(remainingTime);
                    TextView expireTime = new TextView(mContext);
                    expireTime.setText(Utils.timeFromMillis(pokemonMarker.getTimestamp()));
                    expireTime.setGravity(Gravity.CENTER);
                    info.addView(expireTime);
                }
                if (timestamp != -1 && (countdownMarker == null || !countdownMarker.equals(m.getId()))) {
                    countdownMarker = m.getId();
                    new CountDownTimer(timestamp - System.currentTimeMillis(), 1000) {

                        public void onTick(long millisUntilFinished) {
                            if (markers.contains(m) && m.isInfoWindowShown())
                                m.showInfoWindow();
                            else
                                cancel();
                        }

                        @Override
                        public void onFinish() {
                            countdownMarker = null;
                        }
                    }.start();
                }
            }
            return info;
        }
    });
    update();
}

From source file:com.sutromedia.android.core.PhotoActivity.java

public void onSetupView(View view, int viewId) {
    final IPhoto photo = getCurrentPhoto();
    if (photo != null) {

        int backgroundId = (viewId == R.layout.image_view_inside) ? R.drawable.attrib_inside
                : R.drawable.attrib_outside;

        Drawable background = getResources().getDrawable(backgroundId);
        background.setAlpha(155);// ww w  . j ava 2 s  . c o m
        view.findViewById(R.image.licenseGroup).setBackgroundDrawable(background);
        setVisibility(view, R.image.caption, !mInSlideShow && !isSubsetOnEntry());
        TextView caption = (TextView) view.findViewById(R.image.caption);
        String entryName = photo.getEntryName();
        if (entryName != null) {
            entryName = entryName.replace(' ', '\u00A0');
            entryName += "\u00A0\u00A0\u25B6";
        }
        caption.setText(entryName);
        caption.setSingleLine(true);
        caption.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                onReceiveEntry(new NavigationDetailWeb(photo.getEntryId()));
            }
        });

        setVisibility(view, R.image.licenseGroup, !mInSlideShow);
        Integer[] icons = PhotoLicence.getIcons(photo);
        setImageView(view, R.image.license1, 0, icons);
        setImageView(view, R.image.license2, 1, icons);
        TextView owner = (TextView) view.findViewById(R.image.owner);
        if (icons.length > 0) {
            owner.setText(photo.getAuthor());
        } else {
            view.findViewById(R.image.licenseGroup).setVisibility(View.GONE);
        }

        String url = photo.getUrl();
        View licenceGroup = view.findViewById(R.image.licenseGroup);
        if (url != null && url.length() > 0) {
            owner.setTextColor(Color.rgb(0x19, 0x49, 0x90));
            owner.setTypeface(null, Typeface.BOLD);

            licenceGroup.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    onReceiveEntry(new NavigationWeb(photo.getUrl()));
                }
            });
        } else {
            owner.setTypeface(null, Typeface.NORMAL);
            owner.setTextColor(Color.WHITE);
            licenceGroup.setOnClickListener(null);
        }

        setupTouchOnPlayButton();
        setVisibility(R.image.play_slideshow, !mInSlideShow && mShowSlideShowControls);
        setVisibility(R.image.loading, mMissingPhoto);
        setVisibility(R.image.wait, mMissingPhoto && isOnline());

        String missingTextTemplate = getString(
                mMissingPhoto && isOnline() ? R.string.missing_photo : R.string.missing_not_online);
        String missingText = String.format(missingTextTemplate, mCurrentImage + 1, getImageCountInSet());

        setText(R.image.missing, missingText);
    }
}

From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java

/**
 * update View of footer with income, expenses and difference
 *
 * @param footer//from   ww  w  .  ja  v  a2s  . c om
 * @param income
 * @param expenses
 */
private void updateListViewFooter(View footer, double income, double expenses) {
    if (footer == null) {
        return;
    }
    TextView txtIncome = (TextView) footer.findViewById(R.id.textViewIncome);
    TextView txtExpenses = (TextView) footer.findViewById(R.id.textViewExpenses);
    TextView txtDifference = (TextView) footer.findViewById(R.id.textViewDifference);

    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());

    //set income
    txtIncome.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(),
            MoneyFactory.fromDouble(income)));
    txtIncome.setTypeface(null, Typeface.BOLD);
    //set expenses
    txtExpenses.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(),
            MoneyFactory.fromDouble(Math.abs(expenses))));
    txtExpenses.setTypeface(null, Typeface.BOLD);
    //set difference
    txtDifference.setText(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(),
            MoneyFactory.fromDouble(income - Math.abs(expenses))));
    txtDifference.setTypeface(null, Typeface.BOLD);
    //change colors
    UIHelper uiHelper = new UIHelper(getActivity());
    if (income - Math.abs(expenses) < 0) {
        txtDifference.setTextColor(
                ContextCompat.getColor(getActivity(), uiHelper.resolveAttribute(R.attr.holo_red_color_theme)));
    } else {
        txtDifference.setTextColor(ContextCompat.getColor(getActivity(),
                uiHelper.resolveAttribute(R.attr.holo_green_color_theme)));
    }
}

From source file:com.eurotong.orderhelperandroid.OrderMenuActivity.java

void SetStyleForOrderedMenu(VMMenulistOrder menu, TextView textViewOrderCount) {
    if (menu.OrderCount > 0) {
        textViewOrderCount.setTextColor(Color.RED);
        //textViewOrderCount.setTextSize((float) (textCountSize*1.5));
        //textViewOrderCount.setTextSize((float) (textCountSize));
        textViewOrderCount.setTypeface(null, Typeface.BOLD);
    } else {//from  w w w .j  a  v  a 2s .  co m
        textViewOrderCount.setTextColor(Color.BLACK);
        //textViewOrderCount.setTextSize((float) (textCountSize));
        textViewOrderCount.setTypeface(null, Typeface.NORMAL);
    }
}

From source file:com.hybunion.member.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        TextView tab = (TextView) tabsContainer.getChildAt(i);

        tab.setLayoutParams(defaultTabLayoutParams);
        tab.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            tab.setPadding(0, 0, 0, 0);/*  ww w  .  j  av a 2 s .  c  om*/
        } else {
            tab.setPadding(tabPadding, 0, tabPadding, 0);
        }
        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        tab.setTypeface(tabTypeface, tabTypefaceStyle);
        tab.setTextColor(tabTextColor);

    }

}

From source file:com.eccyan.widget.SpinningTabStrip.java

private void notSelected(View tab) {
    TextView title = (TextView) tab.findViewById(R.id.tab_title);
    if (title != null) {
        title.setTypeface(tabTypeface, tabTypefaceStyle);
        title.setAlpha(tabTextAlpha);//from   w w  w . j  a v  a 2s . co m
    }
}

From source file:com.eccyan.widget.SpinningTabStrip.java

private void selected(View tab) {
    TextView title = (TextView) tab.findViewById(R.id.tab_title);
    if (title != null) {
        title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
        title.setAlpha(tabTextSelectedAlpha);
    }/* ww  w .  java 2 s .c  o m*/
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

public TextView createTitleTextView() {
    TextView title_textview = new TextView(this);
    title_textview.setTextSize(20);/* www  .  ja v a  2  s . co m*/
    title_textview.setTextColor(getResources().getColor(R.color.darkGray));
    title_textview.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
    return title_textview;
}

From source file:com.hybris.mobile.app.commerce.fragment.ProductDetailFragmentBase.java

/**
 * Create table to show data in a table/*  ww  w.  ja va 2s .  c o m*/
 *
 * @param volumePricingTable : Table which contains from volume pricing for the current product
 */
protected void createVolumePricingTable(TableLayout volumePricingTable) {
    if (mProduct.getVolumePrices() != null) {
        TableRow headerRow = new TableRow(getActivity());

        TextView header1 = new TextView(getActivity());
        header1.setText(getString(R.string.product_detail_volume_qty));
        header1.setTypeface(null, Typeface.BOLD);
        headerRow.addView(header1);

        TextView header2 = new TextView(getActivity());
        header2.setText(getString(R.string.product_detail_volume_price));
        header2.setTypeface(null, Typeface.BOLD);
        headerRow.addView(header2);

        if (mProduct.getVolumePrices().size() > 5) {
            TextView header3 = new TextView(getActivity());
            header3.setText(getString(R.string.product_detail_volume_qty));
            header3.setTypeface(null, Typeface.BOLD);
            headerRow.addView(header3);

            TextView header4 = new TextView(getActivity());
            header4.setText(getString(R.string.product_detail_volume_price));
            header4.setTypeface(null, Typeface.BOLD);
            headerRow.addView(header4);
        }
        volumePricingTable.addView(headerRow);

        for (Price volumePrice : mProduct.getVolumePrices()) {
            TableRow contentRow = new TableRow(getActivity());

            if (volumePrice != null) {
                TextView content1 = new TextView(getActivity());
                content1.setText(volumePrice.getMinQuantity() + " - " + volumePrice.getMaxQuantity());
                contentRow.addView(content1);

                TextView content2 = new TextView(getActivity());
                content2.setText(volumePrice.getFormattedValue());
                contentRow.addView(content2);

                if (mProduct.getVolumePrices().size() > 5) {
                    TextView content3 = new TextView(getActivity());
                    content3.setText(volumePrice.getMinQuantity() + " - " + volumePrice.getMaxQuantity());
                    contentRow.addView(content3);

                    TextView content4 = new TextView(getActivity());
                    content4.setText(volumePrice.getFormattedValue());
                    contentRow.addView(content4);
                }
            } else {
                Log.d(TAG, "Price or Stock is null");
            }

            volumePricingTable.addView(contentRow);
        }
    }

}

From source file:com.eccyan.widget.SpinningTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < realTabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        if (!(pager.getAdapter() instanceof CustomTabProvider)) {
            v.setBackgroundResource(tabBackgroundResId);
        }//w ww  . j a  v  a  2s .co m
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());

        TextView tabTitle = (TextView) v.findViewById(R.id.tab_title);
        if (tabTitle != null) {
            tabTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tabTitle.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tabTitle.setTextColor(tabTextColor);
            }
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tabTitle.setAllCaps(true);
                } else {
                    tabTitle.setText(tabTitle.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}