Example usage for android.graphics Typeface SANS_SERIF

List of usage examples for android.graphics Typeface SANS_SERIF

Introduction

In this page you can find the example usage for android.graphics Typeface SANS_SERIF.

Prototype

Typeface SANS_SERIF

To view the source code for android.graphics Typeface SANS_SERIF.

Click Source Link

Document

The NORMAL style of the default sans serif typeface.

Usage

From source file:net.zorgblub.typhon.Configuration.java

private FontFamily getFontFamily(String fontKey, String defaultVal) {

    String fontFace = settings.getString(fontKey, defaultVal);

    if (!fontCache.containsKey(fontFace)) {

        if ("mamelon".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "Mamelon", true));
        } else if ("boku2r".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "Boku2", true));
        } else if ("kokoro".equalsIgnoreCase(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "Kokoro", true));
        } else if ("gen_book_bas".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "GentiumBookBasic", false));
        } else if ("gen_bas".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "GentiumBasic", false));
        } else if ("frankruehl".equalsIgnoreCase(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "FrankRuehl", false));
        } else {//from w  w w .j  ava2s  .  c  om

            Typeface face = Typeface.SANS_SERIF;
            if ("sans".equals(fontFace)) {
                face = Typeface.SANS_SERIF;
            } else if ("serif".equals(fontFace)) {
                face = Typeface.SERIF;
            } else if ("mono".equals(fontFace)) {
                face = Typeface.MONOSPACE;
            } else if ("default".equals(fontFace)) {
                face = Typeface.DEFAULT;
            }

            fontCache.put(fontFace, new FontFamily(fontFace, face));
        }
    }

    return fontCache.get(fontFace);
}

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

public TextView createTitleTextView() {
    TextView title_textview = new TextView(this);
    title_textview.setTextSize(20);/*from w  w w  . j  ava2s.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.example.drugsformarinemammals.Dose_Information.java

public TextView createInformationTextView() {
    TextView information_textview = new TextView(this);
    information_textview.setTextColor(Color.BLACK);
    information_textview.setTextSize(16);
    information_textview.setTypeface(Typeface.SANS_SERIF);
    return information_textview;
}

From source file:com.jjoe64.graphview_demos.fragments.StartSensors.java

void loadDefaultSettingValues() {
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
        mDisplayType = Integer.valueOf(res);

        res = pref.getString("fontsize_list", Integer.toString(12));
        mTextFontSize = Integer.valueOf(res);

        res = pref.getString("typeface_list", Integer.toString(3));
        switch (Integer.valueOf(res)) {
        case 0://from   w w  w .  ja  va2 s.co m
            mTextTypeface = Typeface.DEFAULT;
            break;
        case 1:
            mTextTypeface = Typeface.SANS_SERIF;
            break;
        case 2:
            mTextTypeface = Typeface.SERIF;
            break;
        case 3:
            mTextTypeface = Typeface.MONOSPACE;
            break;
        }
        //mTvSerial.setTypeface(mTextTypeface);
        //etWrite.setTypeface(mTextTypeface);

        res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mReadLinefeedCode = Integer.valueOf(res);

        res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mWriteLinefeedCode = Integer.valueOf(res);

        res = pref.getString("email_edittext", "@gmail.com");
        mEmailAddress = res;

        res = pref.getString("baudrate_list", Integer.toString(57600));
        mBaudrate = Integer.valueOf(res);

        res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
        mDataBits = Integer.valueOf(res);

        res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
        mParity = Integer.valueOf(res);

        res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
        mStopBits = Integer.valueOf(res);

        res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
        mFlowControl = Integer.valueOf(res);
    }

From source file:jp.ksksue.app.terminal.AndroidUSBSerialMonitorLite.java

void loadDefaultSettingValues() {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
    mDisplayType = Integer.valueOf(res);

    res = pref.getString("fontsize_list", Integer.toString(12));
    mTextFontSize = Integer.valueOf(res);

    res = pref.getString("typeface_list", Integer.toString(3));
    switch (Integer.valueOf(res)) {
    case 0:/* w  w  w. j  a  v  a 2 s . co m*/
        mTextTypeface = Typeface.DEFAULT;
        break;
    case 1:
        mTextTypeface = Typeface.SANS_SERIF;
        break;
    case 2:
        mTextTypeface = Typeface.SERIF;
        break;
    case 3:
        mTextTypeface = Typeface.MONOSPACE;
        break;
    }
    mTvSerial.setTypeface(mTextTypeface);
    etWrite.setTypeface(mTextTypeface);

    res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
    mReadLinefeedCode = Integer.valueOf(res);

    res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
    mWriteLinefeedCode = Integer.valueOf(res);

    res = pref.getString("email_edittext", "@gmail.com");
    mEmailAddress = res;

    res = pref.getString("baudrate_list", Integer.toString(9600));
    mBaudrate = Integer.valueOf(res);

    res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
    mDataBits = Integer.valueOf(res);

    res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
    mParity = Integer.valueOf(res);

    res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
    mStopBits = Integer.valueOf(res);

    res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
    mFlowControl = Integer.valueOf(res);

    res = pref.getString("play_interval", "3");
    mPlayIntervalSeconds = Integer.valueOf(res);
}

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

public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name,
        String group_name, String animal_family, String animal_name, String animal_category,
        ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) {

    String doseAmount;/*from  www  .j  a va  2s .com*/
    String dosePosology;
    String doseRoute;
    String doseBookReference;
    String doseArticleReference;
    for (int k = 0; k < dose.size(); k++) {
        if (k > 0) {
            dose_data = new TableRow(this);
        }

        doseAmount = dose.get(k).getAmount();
        dosePosology = dose.get(k).getPosology();
        doseRoute = dose.get(k).getRoute();
        doseBookReference = dose.get(k).getBookReference();
        doseArticleReference = dose.get(k).getArticleReference();

        //Dose amount data

        TextView textView_animal_dose_amount = new TextView(this);
        textView_animal_dose_amount.setText(doseAmount);
        textView_animal_dose_amount.setSingleLine(false);
        textView_animal_dose_amount.setTextColor(Color.BLACK);
        textView_animal_dose_amount.setTextSize(15);
        textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDoseAmount.gravity = Gravity.CENTER;
        dose_data.addView(textView_animal_dose_amount, paramsDoseAmount);

        //Dose posology data

        TextView textView_animal_dose_posology = new TextView(this);
        textView_animal_dose_posology.setText(dosePosology);
        textView_animal_dose_posology.setSingleLine(false);
        textView_animal_dose_posology.setTextColor(Color.BLACK);
        textView_animal_dose_posology.setTextSize(15);
        textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDosePosology.gravity = Gravity.CENTER;
        if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology"))
                || screenWidth >= 600)
            dose_data.addView(textView_animal_dose_posology, paramsDosePosology);

        //Dose route data

        TextView textView_animal_dose_route = new TextView(this);
        textView_animal_dose_route.setText(doseRoute);
        textView_animal_dose_route.setSingleLine(false);
        textView_animal_dose_route.setTextColor(Color.BLACK);
        textView_animal_dose_route.setTextSize(15);
        textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        } else {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        }

        //Dose reference data

        TextView textView_animal_dose_reference = new TextView(this);
        if (!doseBookReference.equals(""))
            textView_animal_dose_reference.setText(doseBookReference);
        else if (!doseArticleReference.equals("")) {
            if (!references.contains(doseArticleReference)) {
                references.add(references.size(), doseArticleReference);
                Article_Reference article_reference = new Article_Reference(reference_index,
                        doseArticleReference);
                references_index.add(references_index.size(), article_reference);
                reference_index++;
            }
            int article_index = references.indexOf(doseArticleReference);
            textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")");
        }
        textView_animal_dose_reference.setSingleLine(false);
        textView_animal_dose_reference.setTextColor(Color.BLACK);
        textView_animal_dose_reference.setTextSize(15);
        textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        } else {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        }

        //Specific note index

        ArrayList<String> specific_notes = new ArrayList<String>();
        specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family,
                animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference);

        String index = "";
        for (int m = 0; m < specific_notes.size(); m++) {
            String note = specific_notes.get(m);
            if (!notes.contains(note)) {
                notes.add(notes.size(), note);
            }
            index += "(" + (notes.indexOf(note) + 1) + ")  ";
        }

        TextView textView_specific_note_index = new TextView(this);
        textView_specific_note_index.setText(index);
        textView_specific_note_index.setSingleLine(false);
        textView_specific_note_index.setTextColor(Color.BLACK);
        textView_specific_note_index.setTextSize(15);
        textView_specific_note_index.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600 && screenWidth < 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else if (screenWidth >= 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note"))
                    || screenWidth >= 600)
                dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        }

        dose_table.addView(dose_data);

    }
}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

private void displayArtistInfo_bk(JSONObject j) throws JSONException {
    if (imageLoader == null)
        imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited())
        imageLoader.init(config);/*from w w w. jav a  2s  .c o  m*/

    Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString());

    JSONObject j_artist_info = j.getJSONObject("artist");

    tArtistName.setText(j_artist_info.getString("name"));
    final JSONObject urls = j_artist_info.optJSONObject("urls");
    final JSONArray videos = j_artist_info.optJSONArray("video");
    final JSONArray images = j_artist_info.optJSONArray("images");
    final String fm_image = j.optString("fm_image");
    final JSONArray available_images = new JSONArray();
    ArrayList<String> image_urls = new ArrayList<String>();

    if (fm_image != null) {
        image_urls.add(fm_image);
    }

    Log.i("musicInfo", images.toString());

    if (images != null) {
        for (int i = 0; i < images.length(); i++) {
            JSONObject image = images.getJSONObject(i);
            int width = image.optInt("width", 0);
            int height = image.optInt("height", 0);
            String url = image.optString("url", "");
            Log.i("musicInfo", i + ": " + url);
            if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) {
                //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) {
                image_urls.add(url);
                Log.i("musicInfo", "Selected: " + url);
                //available_images.put(image);
            }
        }

        int random = (int) (Math.random() * image_urls.size());
        final String f_url = image_urls.get(random);

        //int random = (int) (Math.random() * available_images.length());
        //final JSONObject fImage = available_images.length()>0?available_images.getJSONObject(random > images.length() ? 0 : random):images.getJSONObject(0);

        Log.i("musicInfo",
                "Total image#=" + available_images.length() + " Selected image#=" + random + " " + f_url);

        imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String imageUri, View view) {

            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                lLinkList.removeAllViews();
                //String attr = fImage.optJSONObject("license").optString("attribution");
                //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr));
                if (urls != null) {
                    String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url",
                            "twitter_url" };
                    for (int i = 0; i < jsonName.length; i++) {
                        if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) {
                            Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i]));
                            TextView tv = new TextView(getApplicationContext());
                            tv.setTextSize(11);
                            tv.setPadding(16, 16, 16, 16);
                            tv.setTextColor(Color.LTGRAY);
                            tv.setTypeface(Typeface.SANS_SERIF);
                            tv.setGravity(Gravity.CENTER_VERTICAL);
                            tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                    ViewGroup.LayoutParams.WRAP_CONTENT));

                            switch (jsonName[i]) {
                            case "official_url":
                                tv.setText("HOME.");
                                break;
                            case "wikipedia_url":
                                tv.setText("WIKI.");
                                break;
                            case "mb_url":
                                tv.setText("Music Brainz.");
                                break;
                            case "lastfm_url":
                                tv.setText("Last FM.");
                                break;
                            case "twitter_url":
                                tv.setText("Twitter.");
                                break;
                            }

                            try {
                                tv.setTag(urls.getString(jsonName[i]));
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            tv.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Intent intent = new Intent();
                                    intent.setAction(Intent.ACTION_VIEW);
                                    intent.addCategory(Intent.CATEGORY_BROWSABLE);
                                    intent.setData(Uri.parse((String) v.getTag()));
                                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                    startActivity(intent);
                                    Toast.makeText(getApplicationContext(), "Open the Link...",
                                            Toast.LENGTH_SHORT).show();
                                    //finish();
                                }
                            });
                            lLinkList.addView(tv);
                        }
                    }
                } else {
                    TextView tv = new TextView(getApplicationContext());
                    tv.setTextSize(11);
                    tv.setPadding(16, 16, 16, 16);
                    tv.setTextColor(Color.LTGRAY);
                    tv.setTypeface(Typeface.SANS_SERIF);
                    tv.setGravity(Gravity.CENTER_VERTICAL);
                    tv.setText("Sorry, No Link Here...");
                    lLinkList.addView(tv);
                }

                if (videos != null) {
                    jVideoArray = videos;
                    mAdapter = new StaggeredViewAdapter(getApplicationContext(),
                            android.R.layout.simple_list_item_1, generateImageData(videos));
                    //if (mData == null) {
                    mData = generateImageData(videos);
                    //}

                    //mAdapter.clear();

                    for (JSONObject data : mData) {
                        mAdapter.add(data);
                    }
                    mGridView.setAdapter(mAdapter);
                } else {

                }

                adjBottomColor(((ImageView) view).getDrawable());
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {

            }
        });
    }

}

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

private void displayMessage(String messageTitle, String message) {
    AlertDialog.Builder myalert = new AlertDialog.Builder(this);

    TextView title = new TextView(this);
    title.setTypeface(Typeface.SANS_SERIF);
    title.setTextSize(20);/*from www  .  j  av  a2  s  .  c om*/
    title.setTextColor(getResources().getColor(R.color.blue));
    title.setPadding(8, 8, 8, 8);
    title.setText("Synchronization");
    title.setGravity(Gravity.CENTER_VERTICAL);

    LinearLayout layout = new LinearLayout(this);
    TextView text = new TextView(this);
    text.setTypeface(Typeface.SANS_SERIF);
    text.setTextSize(20);
    text.setPadding(10, 10, 10, 10);
    text.setText(message);
    layout.addView(text);

    myalert.setView(layout);
    myalert.setCustomTitle(title);
    myalert.setCancelable(true);
    myalert.show();

}

From source file:org.openintents.notepad.NoteEditor.java

private boolean setRemoteStyle(String styleName, int size) {
    if (TextUtils.isEmpty(styleName)) {
        if (DEBUG) {
            Log.e(TAG, "Empty style name: " + styleName);
        }/*from   w  ww  .jav  a  2 s.c o m*/
        return false;
    }

    PackageManager pm = getPackageManager();

    String packageName = ThemeUtils.getPackageNameFromStyle(styleName);

    if (packageName == null) {
        Log.e(TAG, "Invalid style name: " + styleName);
        return false;
    }

    Context c = null;
    try {
        c = createPackageContext(packageName, 0);
    } catch (NameNotFoundException e) {
        Log.e(TAG, "Package for style not found: " + packageName + ", " + styleName);
        return false;
    }

    Resources res = c.getResources();

    int themeid = res.getIdentifier(styleName, null, null);
    if (DEBUG) {
        Log.d(TAG, "Retrieving theme: " + styleName + ", " + themeid);
    }

    if (themeid == 0) {
        Log.e(TAG, "Theme name not found: " + styleName);
        return false;
    }

    try {
        ThemeAttributes ta = new ThemeAttributes(c, packageName, themeid);

        mTextTypeface = ta.getString(ThemeNotepad.TEXT_TYPEFACE);
        if (DEBUG) {
            Log.d(TAG, "textTypeface: " + mTextTypeface);
        }

        mCurrentTypeface = null;

        // Look for special cases:
        if ("monospace".equals(mTextTypeface)) {
            mCurrentTypeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL);
        } else if ("sans".equals(mTextTypeface)) {
            mCurrentTypeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
        } else if ("serif".equals(mTextTypeface)) {
            mCurrentTypeface = Typeface.create(Typeface.SERIF, Typeface.NORMAL);
        } else if (!TextUtils.isEmpty(mTextTypeface)) {

            try {
                if (DEBUG) {
                    Log.d(TAG, "Reading typeface: package: " + packageName + ", typeface: " + mTextTypeface);
                }
                Resources remoteRes = pm.getResourcesForApplication(packageName);
                mCurrentTypeface = Typeface.createFromAsset(remoteRes.getAssets(), mTextTypeface);
                if (DEBUG) {
                    Log.d(TAG, "Result: " + mCurrentTypeface);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Package not found for Typeface", e);
            }
        }

        mTextUpperCaseFont = ta.getBoolean(ThemeNotepad.TEXT_UPPER_CASE_FONT, false);

        mTextColor = ta.getColor(ThemeNotepad.TEXT_COLOR, android.R.color.white);

        if (DEBUG) {
            Log.d(TAG, "textColor: " + mTextColor);
        }

        if (size == 0) {
            mTextSize = getTextSizeTiny(ta);
        } else if (size == 1) {
            mTextSize = getTextSizeSmall(ta);
        } else if (size == 2) {
            mTextSize = getTextSizeMedium(ta);
        } else {
            mTextSize = getTextSizeLarge(ta);
        }
        if (DEBUG) {
            Log.d(TAG, "textSize: " + mTextSize);
        }

        if (mText != null) {
            mBackgroundPadding = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING, -1);
            int backgroundPaddingLeft = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_LEFT,
                    mBackgroundPadding);
            int backgroundPaddingTop = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_TOP,
                    mBackgroundPadding);
            int backgroundPaddingRight = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_RIGHT,
                    mBackgroundPadding);
            int backgroundPaddingBottom = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_BOTTOM,
                    mBackgroundPadding);

            if (DEBUG) {
                Log.d(TAG,
                        "Padding: " + mBackgroundPadding + "; " + backgroundPaddingLeft + "; "
                                + backgroundPaddingTop + "; " + backgroundPaddingRight + "; "
                                + backgroundPaddingBottom + "; ");
            }

            try {
                Resources remoteRes = pm.getResourcesForApplication(packageName);
                int resid = ta.getResourceId(ThemeNotepad.BACKGROUND, 0);
                if (resid != 0) {
                    Drawable d = remoteRes.getDrawable(resid);
                    mText.setBackgroundDrawable(d);
                } else {
                    // remove background
                    mText.setBackgroundResource(0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Package not found for Theme background.", e);
            } catch (Resources.NotFoundException e) {
                Log.e(TAG, "Resource not found for Theme background.", e);
            }

            // Apply padding
            if (mBackgroundPadding >= 0 || backgroundPaddingLeft >= 0 || backgroundPaddingTop >= 0
                    || backgroundPaddingRight >= 0 || backgroundPaddingBottom >= 0) {
                mText.setPadding(backgroundPaddingLeft, backgroundPaddingTop, backgroundPaddingRight,
                        backgroundPaddingBottom);
            } else {
                // 9-patches do the padding automatically
                // todo clear padding
            }
        }

        mLinesMode = ta.getInteger(ThemeNotepad.LINE_MODE, 2);
        mLinesColor = ta.getColor(ThemeNotepad.LINE_COLOR, 0xFF000080);

        if (DEBUG) {
            Log.d(TAG, "line color: " + mLinesColor);
        }

        return true;

    } catch (UnsupportedOperationException e) {
        // This exception is thrown e.g. if one attempts
        // to read an integer attribute as dimension.
        Log.e(TAG, "UnsupportedOperationException", e);
        return false;
    } catch (NumberFormatException e) {
        // This exception is thrown e.g. if one attempts
        // to read a string as integer.
        Log.e(TAG, "NumberFormatException", e);
        return false;
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

public Typeface getTypeface(String fontName, int fontStyle) {
    Typeface tf = null;/* w w  w  . j ava2s  .  co  m*/
    if (fontName.toLowerCase().contains("book")) {
        tf = Typeface.create(Typeface.DEFAULT, fontStyle);
    } else if (fontName.toLowerCase().contains("default")) {
        tf = Typeface.create(Typeface.DEFAULT, fontStyle);
    } else if (fontName.toLowerCase().contains("mono")) {
        tf = Typeface.create(Typeface.MONOSPACE, fontStyle);
    } else if ((fontName.toLowerCase().contains("sans"))) {
        tf = Typeface.create(Typeface.SANS_SERIF, fontStyle);
    } else if ((fontName.toLowerCase().contains("serif"))) {
        tf = Typeface.create(Typeface.SERIF, fontStyle);
    }
    return tf;
}