Example usage for android.graphics Typeface BOLD

List of usage examples for android.graphics Typeface BOLD

Introduction

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

Prototype

int BOLD

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

Click Source Link

Usage

From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.view_zenoss_device_fragment, container, false);

    Typeface titlesTypeFace = Typeface.create("sans-serif-light", Typeface.BOLD);

    deviceTitle = (TextView) rootView.findViewById(R.id.DeviceTitle);
    deviceTitle.setTypeface(titlesTypeFace);

    loadAverageGraphView = (ImageView) rootView.findViewById(R.id.loadAverageGraph);
    CPUGraphView = (ImageView) rootView.findViewById(R.id.CPUGraph);
    MemoryGraphView = (ImageView) rootView.findViewById(R.id.MemoryGraph);

    snmpAgent = (TextView) rootView.findViewById(R.id.snmpAgent);
    snmpAgent.setTypeface(titlesTypeFace);
    snmpContact = (TextView) rootView.findViewById(R.id.snmpContact);
    snmpContact.setTypeface(titlesTypeFace);
    snmpLocation = (TextView) rootView.findViewById(R.id.snmpLocation);
    snmpLocation.setTypeface(titlesTypeFace);
    Uptime = (TextView) rootView.findViewById(R.id.uptime);
    Uptime.setTypeface(titlesTypeFace);//www .j  a  v a 2  s . c o  m
    MemoryRAM = (TextView) rootView.findViewById(R.id.memory_ram);
    MemoryRAM.setTypeface(titlesTypeFace);
    MemorySwap = (TextView) rootView.findViewById(R.id.memory_swap);
    MemorySwap.setTypeface(titlesTypeFace);
    LastCollected = (TextView) rootView.findViewById(R.id.lastCollected);
    LastCollected.setTypeface(titlesTypeFace);

    hsv = (HorizontalScrollView) rootView.findViewById(R.id.horizontalScrollView);

    try {
        ImageView deviceRepImg = ((ImageView) rootView.findViewById(R.id.deviceRepImg));
        deviceRepImg.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Random r = new Random();
        deviceRepImg.setImageResource(mThumbIds[r.nextInt(mThumbIds.length)]);
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "ImageRand", e);
    }

    return rootView;
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE IMAGE ROW//from   w ww . j ava2  s  .c  om
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f);
    ImageView img = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value"));
    img.setImageResource(context.getResources().getIdentifier(path, null, null));
    img.setPadding(0, 3, 0, 3);
    container_layout.addView(img, value_params);

    linear.addView(container_layout);
    return linear;
}

From source file:com.google.android.apps.iosched.util.UIUtils.java

public static void updateTimeAndLivestreamBlockUI(final Context context, long blockStart, long blockEnd,
        boolean hasLivestream, View backgroundView, TextView titleView, TextView subtitleView,
        CharSequence subtitle) {//from w  w  w. j  a v a2 s.c o m
    long currentTimeMillis = getCurrentTime(context);

    boolean past = (currentTimeMillis > blockEnd && currentTimeMillis < CONFERENCE_END_MILLIS);
    boolean present = (blockStart <= currentTimeMillis && currentTimeMillis <= blockEnd);

    final Resources res = context.getResources();
    if (backgroundView != null) {
        backgroundView.setBackgroundColor(past ? res.getColor(R.color.past_background_color) : 0);
    }

    if (titleView != null) {
        titleView.setTypeface(Typeface.SANS_SERIF, past ? Typeface.NORMAL : Typeface.BOLD);
    }

    if (subtitleView != null) {
        boolean empty = true;
        SpannableStringBuilder sb = new SpannableStringBuilder(); // TODO: recycle
        if (subtitle != null) {
            sb.append(subtitle);
            empty = false;
        }

        if (present) {
            if (sNowPlayingText == null) {
                sNowPlayingText = Html.fromHtml(context.getString(R.string.now_playing_badge));
            }
            if (!empty) {
                sb.append("  ");
            }
            sb.append(sNowPlayingText);

            if (hasLivestream) {
                if (sLivestreamNowText == null) {
                    sLivestreamNowText = Html
                            .fromHtml("&nbsp;&nbsp;" + context.getString(R.string.live_now_badge));
                }
                sb.append(sLivestreamNowText);
            }
        } else if (hasLivestream) {
            if (sLivestreamAvailableText == null) {
                sLivestreamAvailableText = Html.fromHtml(context.getString(R.string.live_available_badge));
            }
            if (!empty) {
                sb.append("  ");
            }
            sb.append(sLivestreamAvailableText);
        }

        subtitleView.setText(sb);
    }
}

From source file:com.ekuater.labelchat.ui.widget.PagerSlidingTabStrip.java

private int indexToTextStyle(int index, int defaultStyle) {
    int style;/*from   w w  w  . j a  v  a 2  s.  c o m*/

    switch (index) {
    case 0:
        style = Typeface.NORMAL;
        break;
    case 1:
        style = Typeface.BOLD;
        break;
    case 2:
        style = Typeface.ITALIC;
        break;
    case 3:
        style = Typeface.BOLD_ITALIC;
        break;
    default:
        style = defaultStyle;
        break;

    }
    return style;
}

From source file:com.xbm.android.matisse.internal.ui.widget.CheckView.java

private void initTextPaint() {
    if (mTextPaint == null) {
        mTextPaint = new TextPaint();
        mTextPaint.setAntiAlias(true);//from  w w w . ja va2  s  .  c  om
        mTextPaint.setColor(Color.WHITE);
        mTextPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
        mTextPaint.setTextSize(12.0f * mDensity);
    }
}

From source file:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.event.info.EventDetailInfoAdapter.java

@SuppressWarnings("deprecation")
@Override/* w  w w  .  ja  v  a 2s  .  com*/
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parentView) {
    final EventInfoParent parent = this.fragment.parents.get(groupPosition);
    final EventInfoChild child = parent.getChildren().get(childPosition);
    int itemType = getChildType(groupPosition, childPosition);

    Log.i("GROUPVIEW", "************ init child view!! ************ ");
    Log.i("GROUPVIEW", "COUNT: " + countChildViewCall);
    Log.i("GROUPVIEW", "CHILD TEXT: " + child.getText());
    Log.i("GROUPVIEW", "CHILD TYPE: " + child.getType());

    row = convertView;
    if (row == null) {
        // Inflate event_info_child_item.xml file for child rows
        LayoutInflater inflater = (LayoutInflater) this.fragment.context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.event_info_child_item, parentView, false);
        eventChildViewHolder = new EventInfoChildViewHolder();
        eventChildViewHolder.text = (TextView) row.findViewById(R.id.event_info_attribute_values);
        //         eventChildViewHolder.imgSx = (ImageView) row
        //               .findViewById(R.id.event_info_attribute_value_icon);
        eventChildViewHolder.imgsDx1 = (ImageView) row.findViewById(R.id.event_info_action1);

        eventChildViewHolder.divider = (View) row.findViewById(R.id.event_info_item_divider);

        //this will be added again when it will be possible to cancel/edit the single items
        //         eventChildViewHolder.imgsDx2 = (ImageView) row
        //               .findViewById(R.id.event_info_action2);
        //         eventChildViewHolder.imgsDx3 = (ImageView) row
        //               .findViewById(R.id.event_info_action3);

        row.setTag(eventChildViewHolder);
    } else {
        eventChildViewHolder = (EventInfoChildViewHolder) row.getTag();
    }

    // Get event_info_child_item.xml file elements and set values

    if (child.getTextInBold())
        eventChildViewHolder.text.setTypeface(null, Typeface.BOLD);
    else
        eventChildViewHolder.text.setTypeface(null, Typeface.NORMAL);

    if (!child.getText().contains("http")) {
        eventChildViewHolder.text.setText(child.getText());
    } else {

        if (!child.getText().matches(fragment.getString(R.string.start_url))) {

            Log.i("GROUPVIEW", "make the text part clickable!!!");

            //make the text part clickable
            int i1 = 0;
            int i2 = child.getName().length() - 1;
            eventChildViewHolder.text.setMovementMethod(LinkMovementMethod.getInstance());
            eventChildViewHolder.text.setText(child.getName(), BufferType.SPANNABLE);
            //eventChildViewHolder.text.setAutoLinkMask(Linkify.WEB_URLS);
            //Linkify.addLinks(eventChildViewHolder.text, Linkify.WEB_URLS);
            //String s = "<a href=\" + child.getText() + \">Website</a>";
            //eventChildViewHolder.text.setText(Html.fromHtml(s));

            Spannable mySpannable = (Spannable) eventChildViewHolder.text.getText();
            ClickableSpan myClickableSpan = new ClickableSpan() {
                @Override
                public void onClick(View widget) {
                    //               Toast.makeText(fragment.context,
                    //                     "Open browser ofr url: " + child.getText(),
                    //                     Toast.LENGTH_LONG).show(); 
                    String url = child.getText();
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    fragment.context.startActivity(i);

                }
            };

            //         row.setFocusable(true);
            //         row.setFocusableInTouchMode(true);

            mySpannable.setSpan(myClickableSpan, i1, i2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            //         eventChildViewHolder.text.setText(Html.fromHtml(child.getText()));
            //         eventChildViewHolder.text.setMovementMethod(LinkMovementMethod.getInstance());
        } else
            eventChildViewHolder.text.setText(child.getName());
    }

    if (child.getName().equals("Description")) {
        //Log.i("EVENT", "EventDetailInfoAdapter --> set description to html!!");
        eventChildViewHolder.text.setText(Html.fromHtml(child.getText()));
        eventChildViewHolder.text.setPadding(10, 10, 0, 0);
    }

    // set icon on the left side
    //      if (child.getLeftIconId() != -1) {
    //         Log.i("GROUPVIEW", "CHILD SX ICON ID: " + child.getLeftIconId());
    //         eventChildViewHolder.imgSx.setVisibility(View.VISIBLE);
    //         eventChildViewHolder.imgSx.setImageResource(child.getLeftIconId());
    //
    //         Log.i("IMAGE", "IMG CHILD NAME: "
    //               + child.getText());
    //
    //         Log.i("IMAGE", "IMG ICON WIDTH: "
    //               + eventChildViewHolder.imgSx.getWidth());
    //         
    //      } else {
    //         Log.i("GROUPVIEW", "CHILD SX ICON -1");
    //         if ( (child.getName().equals("email")) || (child.getName().equals("tel")) ){
    //            Log.i("GROUPVIEW", "CHILD NAME: " + child.getName());
    //            eventChildViewHolder.imgSx.setVisibility(View.INVISIBLE);
    //            eventChildViewHolder.text.setPadding(10, 0, 0, 0);
    //         }
    //         else{
    //            eventChildViewHolder.imgSx.setVisibility(View.GONE);
    //            eventChildViewHolder.text.setPadding(10, 10, 0, 0);
    //         }
    //         
    //      }

    // set icon on the left side
    if (child.getLeftIconId() != -1) {
        Log.i("GROUPVIEW", "CHILD SX ICON ID: " + child.getLeftIconId());
        eventChildViewHolder.text.setCompoundDrawablesWithIntrinsicBounds(child.getLeftIconId(), 0, 0, 0);
    } else
        eventChildViewHolder.text.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);

    // set icons on the right side for the items of type 1 (telefono, email)
    if ((child.getRightIconIds() != null) && (child.getType() == 1)) {
        Log.i("GROUPVIEW", "CHILD DX1 ICON ID: " + child.getRightIconIds()[0]);

        eventChildViewHolder.text.setTypeface(null, Typeface.BOLD);

        eventChildViewHolder.imgsDx1.setVisibility(View.VISIBLE);
        eventChildViewHolder.imgsDx1.setImageResource(child.getRightIconIds()[0]);
        eventChildViewHolder.imgsDx1
                .setOnClickListener(new ChildAddIconClickListener(this.fragment.context, child));
    } else {
        Log.i("GROUPVIEW", "CHILD DX1 ICON NULL");
        eventChildViewHolder.imgsDx1.setVisibility(View.INVISIBLE);
    }

    //set divider line height and color
    eventChildViewHolder.divider.setBackgroundColor(fragment.getResources().getColor(child.getDividerColor()));
    eventChildViewHolder.divider.setLayoutParams(
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, child.getDividerHeight()));

    // set icons on the right side for the items of type 0 (single values)
    if ((child.getRightIconIds() != null) && (child.getType() == 0)) {
        Log.i("GROUPVIEW", "CHILD DX1 ICON ID: " + child.getRightIconIds()[0]);
        int iconsNumb = child.getRightIconIds().length;
        Log.i("GROUPVIEW", "ICON NUMMBER: " + iconsNumb);
        eventChildViewHolder.imgsDx1.setVisibility(View.VISIBLE);
        eventChildViewHolder.imgsDx1.setImageResource(child.getRightIconIds()[0]);
        eventChildViewHolder.imgsDx1
                .setOnClickListener(new ChildActionIconClickListener(this.fragment.context, child));
        //this will be added when cancel/edit for single item will be possible
        //         eventChildViewHolder.imgsDx2.setVisibility(View.VISIBLE);
        //         eventChildViewHolder.imgsDx2.setImageResource(child
        //               .getRightIconIds()[1]);
        //         if (iconsNumb == 3)
        //            eventChildViewHolder.imgsDx3.setVisibility(View.VISIBLE);
        //         eventChildViewHolder.imgsDx3.setImageResource(child
        //               .getRightIconIds()[2]);

    } else {
        Log.i("GROUPVIEW", "CHILD DX1 ICON NULL");
        eventChildViewHolder.imgsDx1.setVisibility(View.INVISIBLE);

        //this will be added when cancel/edit for single item will be possible
        //         eventChildViewHolder.imgsDx2.setVisibility(View.INVISIBLE);
        //         eventChildViewHolder.imgsDx3.setVisibility(View.INVISIBLE);
    }

    //      Log.i("GROUPVIEW", "child view: group  POS: " + groupPosition + "!!");
    //      Log.i("GROUPVIEW", "child view: child POS: " + childPosition + "!!");

    countChildViewCall++;

    return row;
}

From source file:org.sirimangalo.meditationplus.AdapterCommit.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View rowView = inflater.inflate(R.layout.list_item_commit, parent, false);

    final View shell = rowView.findViewById(R.id.detail_shell);

    rowView.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w w  .ja v  a 2  s .  c  om*/
        public void onClick(View view) {
            boolean visible = shell.getVisibility() == View.VISIBLE;

            shell.setVisibility(visible ? View.GONE : View.VISIBLE);

            context.setCommitVisible(position, !visible);

        }
    });

    final JSONObject p = values.get(position);

    TextView title = (TextView) rowView.findViewById(R.id.title);
    TextView descV = (TextView) rowView.findViewById(R.id.desc);
    TextView defV = (TextView) rowView.findViewById(R.id.def);
    TextView usersV = (TextView) rowView.findViewById(R.id.users);
    TextView youV = (TextView) rowView.findViewById(R.id.you);

    try {

        if (p.getBoolean("open"))
            shell.setVisibility(View.VISIBLE);

        title.setText(p.getString("title"));
        descV.setText(p.getString("description"));

        String length = p.getString("length");
        String time = p.getString("time");
        final String cid = p.getString("cid");

        String def = "";

        boolean repeat = false;

        if (length.indexOf(":") > 0) {
            repeat = true;
            String[] lengtha = length.split(":");
            def += lengtha[0] + " minutes walking and " + lengtha[1] + " minutes sitting";
        } else
            def += length + " minutes total meditation";

        String period = p.getString("period");

        String day = p.getString("day");

        if (period.equals("daily")) {
            if (repeat)
                def += " every day";
            else
                def += " per day";
        } else if (period.equals("weekly")) {
            if (repeat)
                def += " every " + dow[Integer.parseInt(day)];
            else
                def += " per week";
        } else if (period.equals("monthly")) {
            if (repeat)
                def += " on the " + day
                        + (day.substring(day.length() - 1).equals("1") ? "st"
                                : (day.substring(day.length() - 1).equals("2") ? "nd"
                                        : (day.substring(day.length() - 1).equals("3") ? "rd" : "th")))
                        + " day of the month";
            else
                def += " per month";
        } else if (period.equals("yearly")) {
            if (repeat)
                def += " on the " + day
                        + (day.substring(day.length() - 1).equals("1") ? "st"
                                : (day.substring(day.length() - 1).equals("2") ? "nd"
                                        : (day.substring(day.length() - 1).equals("3") ? "rd" : "th")))
                        + " day of the year";
            else
                def += " per year";
        }

        if (!time.equals("any")) {
            Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            utc.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time.split(":")[0]));
            utc.set(Calendar.MINUTE, Integer.parseInt(time.split(":")[1]));

            Calendar here = Calendar.getInstance();
            here.setTimeInMillis(utc.getTimeInMillis());

            int hours = here.get(Calendar.HOUR_OF_DAY);
            int minutes = here.get(Calendar.MINUTE);

            def += " at " + (time.length() == 4 ? "0" : "") + time.replace(":", "") + "h UTC <i>("
                    + (hours > 12 ? hours - 12 : hours) + ":" + ((minutes < 10 ? "0" : "") + minutes) + " "
                    + (hours > 11 && hours < 24 ? "PM" : "AM") + " your time)</i>";
        }

        defV.setText(Html.fromHtml(def));

        JSONObject usersJ = p.getJSONObject("users");

        ArrayList<String> committedArray = new ArrayList<String>();

        // collect into array

        for (int i = 0; i < usersJ.names().length(); i++) {
            try {
                String j = usersJ.names().getString(i);
                String k = j;
                //                    if(j.equals(p.getString("creator")))
                //                        k = "["+j+"]";
                committedArray.add(k);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        String text = context.getString(R.string.committed) + " ";

        // add spans

        int committed = -1;

        int pos = text.length(); // start after "Committed: "

        text += TextUtils.join(", ", committedArray);
        Spannable span = new SpannableString(text);

        span.setSpan(new StyleSpan(Typeface.BOLD), 0, pos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // bold the "Online: "

        for (int i = 0; i < committedArray.size(); i++) {
            try {

                final String oneCom = committedArray.get(i);
                String userCom = usersJ.getString(oneCom);
                //String userCom = usersJ.getString(oneCom.replace("[", "").replace("]", ""));

                //if(oneCom.replace("[","").replace("]","").equals(loggedUser))
                if (oneCom.equals(loggedUser))
                    committed = Integer.parseInt(userCom);

                int end = pos + oneCom.length();

                ClickableSpan clickable = new ClickableSpan() {

                    @Override
                    public void onClick(View widget) {
                        context.showProfile(oneCom);
                    }

                };
                span.setSpan(clickable, pos, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

                span.setSpan(new UnderlineSpan() {
                    public void updateDrawState(TextPaint tp) {
                        tp.setUnderlineText(false);
                    }
                }, pos, end, 0);

                String color = Utils.makeRedGreen(Integer.parseInt(userCom), true);

                span.setSpan(new ForegroundColorSpan(Color.parseColor("#FF" + color)), pos, end,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

                pos += oneCom.length() + 2;

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        usersV.setText(span);
        usersV.setMovementMethod(new LinkMovementMethod());

        if (loggedUser != null && loggedUser.length() > 0) {
            LinearLayout bl = (LinearLayout) rowView.findViewById(R.id.commit_buttons);
            if (!usersJ.has(loggedUser)) {
                Button commitB = new Button(context);
                commitB.setId(R.id.commit_button);
                commitB.setText(R.string.commit);
                commitB.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
                        nvp.add(new BasicNameValuePair("full_update", "true"));

                        context.doSubmit("commitform_" + cid, nvp, true);
                    }
                });
                bl.addView(commitB);
            } else {
                Button commitB = new Button(context);
                commitB.setId(R.id.uncommit_button);
                commitB.setText(R.string.uncommit);
                commitB.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
                        nvp.add(new BasicNameValuePair("full_update", "true"));

                        context.doSubmit("uncommitform_" + cid, nvp, true);
                    }
                });
                bl.addView(commitB);
            }

            if (loggedUser.equals(p.getString("creator")) || context.isAdmin) {
                Button commitB2 = new Button(context);
                commitB2.setId(R.id.edit_commit_button);
                commitB2.setText(R.string.edit);
                commitB2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Intent i = new Intent(context, ActivityCommit.class);
                        i.putExtra("commitment", p.toString());
                        context.startActivity(i);
                    }
                });
                bl.addView(commitB2);

                Button commitB3 = new Button(context);
                commitB3.setId(R.id.uncommit_button);
                commitB3.setText(R.string.delete);
                commitB3.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
                        nvp.add(new BasicNameValuePair("full_update", "true"));

                        context.doSubmit("delcommitform_" + cid, nvp, true);
                    }
                });
                bl.addView(commitB3);
            }

        }

        if (committed > -1) {
            int color = Color.parseColor("#FF" + Utils.makeRedGreen(committed, false));
            rowView.setBackgroundColor(color);
        }

        if (committed != -1) {
            youV.setText(String.format(context.getString(R.string.you_commit_x), committed));
            youV.setVisibility(View.VISIBLE);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return rowView;
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

private void populateKeyboardRow(KeyboardRow keyboardRow, int keyHeight) {
    Context context = getContext();
    LinearLayout keyContainer = new LinearLayout(context);
    keyContainer.setOrientation(HORIZONTAL);
    keyContainer.setGravity(Gravity.CENTER);

    List<KeyboardKey> keyList = keyboardRow.getKeyList();
    if (keyList != null) {
        for (int i = 0; i < keyList.size(); i++) {
            KeyboardKey keyboardKey = keyList.get(i);
            if (keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_NORMAL) {
                TextView key = new TextView(context);
                key.setGravity(Gravity.CENTER);
                key.setTypeface(mCharTypeface, Typeface.BOLD);
                key.setText(keyboardKey.getCharCode());
                key.setTextSize(16f);//w  ww. j  a  va2s . co  m
                key.setTextColor(
                        ContextCompat.getColorStateList(context, R.color.amharic_key_text_color_selector));
                key.setTag(keyboardKey);
                key.setIncludeFontPadding(false);
                keyContainer.setBaselineAligned(false);
                handleChild(key, keyboardKey.getColumnCount(), keyContainer, keyHeight);
            } else if (keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_BACKSPACE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_SPACE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_NEW_LINE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_ENTER
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_HIDE_KEYBOARD) {
                ImageView child = new ImageView(context);
                child.setImageResource(keyboardKey.getCommandImage());
                int padding = getCustomSize(6);
                child.setPadding(padding, padding, padding, padding);
                child.setTag(keyboardKey);
                handleChild(child, keyboardKey.getColumnCount(), keyContainer, keyHeight);
            }
        }
    }
    addView(keyContainer, new LayoutParams(LayoutParams.MATCH_PARENT, keyHeight));
}

From source file:io.karim.MaterialTabs.java

public MaterialTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from  w w  w . j  av a2 s .  c om*/
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // Get system attrs (android:textSize and android:textColor).
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
    tabTextColorUnselected = a.getColor(TEXT_COLOR_INDEX, textPrimaryColor);

    underlineColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;
    int padding = a.getDimensionPixelSize(PADDING_INDEX, 0);
    paddingLeft = padding > 0 ? padding : a.getDimensionPixelSize(PADDING_LEFT_INDEX, 0);
    paddingRight = padding > 0 ? padding : a.getDimensionPixelSize(PADDING_RIGHT_INDEX, 0);
    a.recycle();

    a = context.obtainStyledAttributes(attrs, R.styleable.MaterialTabs);

    // Get custom attrs of MaterialTabs.
    indicatorColor = a.getColor(R.styleable.MaterialTabs_mtIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.MaterialTabs_mtUnderlineColor, underlineColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtIndicatorHeight, indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtUnderlineHeight, underlineHeight);
    tabPadding = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtTabPaddingLeftRight, tabPadding);
    sameWeightTabs = a.getBoolean(R.styleable.MaterialTabs_mtSameWeightTabs, sameWeightTabs);
    textAllCaps = a.getBoolean(R.styleable.MaterialTabs_mtTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.MaterialTabs_mtPaddingMiddle, isPaddingMiddle);
    tabTypefaceUnselectedStyle = a.getInt(R.styleable.MaterialTabs_mtTextUnselectedStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.MaterialTabs_mtTextSelectedStyle, Typeface.BOLD);
    tabTextColorSelected = a.getColor(R.styleable.MaterialTabs_mtTextColorSelected, textPrimaryColor);

    // Get custom attrs of MaterialRippleLayout.
    rippleColor = a.getColor(R.styleable.MaterialTabs_mtMrlRippleColor, MaterialRippleLayout.DEFAULT_COLOR);
    // Making default ripple highlight color the same as rippleColor but with 1/4 the alpha.
    rippleHighlightColor = Color.argb((int) (Color.alpha(rippleColor) * 0.25), Color.red(rippleColor),
            Color.green(rippleColor), Color.blue(rippleColor));
    rippleHighlightColor = a.getColor(R.styleable.MaterialTabs_mtMrlRippleHighlightColor, rippleHighlightColor);
    rippleDiameterDp = a.getDimension(R.styleable.MaterialTabs_mtMrlRippleDiameter,
            MaterialRippleLayout.DEFAULT_DIAMETER_DP);
    rippleOverlay = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleOverlay,
            MaterialRippleLayout.DEFAULT_RIPPLE_OVERLAY);
    rippleDuration = a.getInt(R.styleable.MaterialTabs_mtMrlRippleDuration,
            MaterialRippleLayout.DEFAULT_DURATION);
    rippleAlphaFloat = a.getFloat(R.styleable.MaterialTabs_mtMrlRippleAlpha,
            MaterialRippleLayout.DEFAULT_ALPHA);
    rippleDelayClick = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleDelayClick,
            MaterialRippleLayout.DEFAULT_DELAY_CLICK);
    rippleFadeDuration = a.getInteger(R.styleable.MaterialTabs_mtMrlRippleFadeDuration,
            MaterialRippleLayout.DEFAULT_FADE_DURATION);
    ripplePersistent = a.getBoolean(R.styleable.MaterialTabs_mtMrlRipplePersistent,
            MaterialRippleLayout.DEFAULT_PERSISTENT);
    rippleInAdapter = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleInAdapter,
            MaterialRippleLayout.DEFAULT_SEARCH_ADAPTER);
    rippleRoundedCornersDp = a.getDimension(R.styleable.MaterialTabs_mtMrlRippleRoundedCorners,
            MaterialRippleLayout.DEFAULT_ROUNDED_CORNERS_DP);

    a.recycle();

    setMarginBottomTabContainer();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.java2s.intents4.IntentsDemo4Activity.java

void addRow(final LinearLayout layout, String label, String hintStr, boolean addRadioGroup) {
    LinearLayout.LayoutParams rowLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams editTextLayoutParams = new LinearLayout.LayoutParams(400,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1);
    if (addRadioGroup) {
        editTextLayoutParams = new LinearLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
    }/*  w  w w .  ja v a  2s  . c  o m*/
    LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0);

    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);
    row.setGravity(Gravity.CENTER_VERTICAL);

    TextView textView = new TextView(this);
    textView.setText(label);
    row.addView(textView);
    EditText editText = new EditText(this);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    editText.setHint(hintStr);
    editText.setLayoutParams(editTextLayoutParams);
    if (!isFirstTime) {
        editText.requestFocus();
    }
    row.addView(editText);

    if (addRadioGroup) {
        LinearLayout groupLayout = new LinearLayout(this);
        groupLayout.setOrientation(LinearLayout.VERTICAL);
        groupLayout.setGravity(Gravity.CENTER_HORIZONTAL);

        RadioGroup group = new RadioGroup(this);
        group.setLayoutParams(new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
                RadioGroup.LayoutParams.WRAP_CONTENT));

        final Button patternButton = new Button(this);
        patternButton.setText(pathPatterns[0]);
        patternButton.setTextSize(8);
        patternButton.setLayoutParams(buttonLayoutParams);
        patternButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String patternButtonText = patternButton.getText().toString().trim();
                if (patternButtonText.equals(pathPatterns[0])) {
                    patternButton.setText(pathPatterns[1]);
                } else if (patternButtonText.equals(pathPatterns[1])) {
                    patternButton.setText(pathPatterns[2]);
                } else if (patternButtonText.equals(pathPatterns[2])) {
                    patternButton.setText(pathPatterns[0]);
                }
            }
        });
        groupLayout.addView(patternButton);
        row.addView(groupLayout);
    }
    Button button = new Button(this);
    button.setTextSize(10);
    button.setTypeface(null, Typeface.BOLD);
    button.setText("X");
    button.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    button.setLayoutParams(buttonLayoutParams);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            layout.removeView((LinearLayout) view.getParent());
        }
    });
    row.addView(button);

    row.setLayoutParams(rowLayoutParams);
    layout.addView(row);
}