Example usage for android.widget TextView setBackgroundDrawable

List of usage examples for android.widget TextView setBackgroundDrawable

Introduction

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

Prototype

@Deprecated
public void setBackgroundDrawable(Drawable background) 

Source Link

Usage

From source file:com.cssweb.android.quote.QHSCGridActivity.java

private void AddViewItem(int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3,
        int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;
    localTextView.setTextSize(f);//from w ww .j  ava  2s. c  om

    localTextView.setGravity(Gravity.CENTER);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); // touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(true);
    Resources localResources = getResources();
    Drawable localDrawable = null;
    if (paramInt4 == 0 && paramInt3 >= 0) {// 
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
}

From source file:com.todoroo.astrid.activity.TaskEditFragment.java

private void setupWaitingOnMe() {
    if (!isNewTask) {
        WaitingOnMe wom = waitingOnMeDao.findByTask(model.getUuid());
        if (wom != null) {
            final View waitingOnMe = getView().findViewById(R.id.waiting_on_me);
            waitingOnMe.setVisibility(View.VISIBLE);

            int themeColor = getResources().getColor(ThemeService.getTaskEditThemeColor());

            TextView dismiss = (TextView) waitingOnMe.findViewById(R.id.wom_dismiss);
            dismiss.setOnClickListener(new OnClickListener() {
                @Override/*www  .  j ava 2  s  . com*/
                public void onClick(View v) {
                    WaitingOnMe template = new WaitingOnMe();
                    template.setValue(WaitingOnMe.DELETED_AT, DateUtilities.now());
                    waitingOnMeDao.update(WaitingOnMe.TASK_UUID.eq(model.getUuid()), template);
                    waitingOnMe.setVisibility(View.GONE);
                }
            });
            dismiss.setTextColor(getResources().getColor(R.color.task_edit_deadline_gray));
            GradientDrawable gd = new GradientDrawable();
            gd.setColor(ThemeService.getDarkVsLight(Color.rgb(0xee, 0xee, 0xee), Color.rgb(0x22, 0x22, 0x22),
                    false));
            gd.setCornerRadius(4.0f);
            dismiss.setBackgroundDrawable(gd);

            TextView ack = (TextView) waitingOnMe.findViewById(R.id.wom_acknowledge);
            ack.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    WaitingOnMe template = new WaitingOnMe();
                    template.setValue(WaitingOnMe.ACKNOWLEDGED, 1);
                    waitingOnMeDao.update(WaitingOnMe.TASK_UUID.eq(model.getUuid()), template);
                    waitingOnMe.setVisibility(View.GONE);
                }
            });
            ack.setTextColor(themeColor);
            gd = new GradientDrawable();
            gd.setColor(ThemeService.getDarkVsLight(Color.WHITE, Color.rgb(0x22, 0x22, 0x22), false));
            gd.setCornerRadius(4.0f);
            ack.setBackgroundDrawable(gd);

            TextView womText = (TextView) waitingOnMe.findViewById(R.id.wom_message);
            womText.setText(getWomText(wom));
            womText.setTextColor(themeColor);

            ImageView womIcon = (ImageView) waitingOnMe.findViewById(R.id.wom_icon);
            womIcon.setImageResource(ThemeService.getTaskEditDrawable(R.drawable.tea_icn_waiting,
                    R.drawable.tea_icn_waiting_lightblue));
        }
    }
}

From source file:com.cssweb.android.base.QuoteGridActivity.java

private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2,
        int paramInt3, int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;

    localTextView.setTextSize(f);/*from  w  ww  .ja  va 2  s.  c  o  m*/
    //??4?
    if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) {

        if (this.mPaint.measureText(paramString) > textWeight)
            localTextView.setTextSize(13);
    }

    if (n2 == paramInt2) {
        String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString;
        localTextView.setText(str);
    } else {
        localTextView.setText(paramString);
    }
    localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); //touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(false);
    if (paramInt4 == 0 && paramInt3 >= 0) {//
        localTextView.setGravity(Gravity.CENTER);
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = getResources().getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 13) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 8) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 10;
        } else if (paramInt3 % 2 == 0) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        //int i9 = (int) Math.max(i8, mPaint.measureText(paramString));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = getResources().getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = getResources().getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 13) {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
            //localTextView.setWidth(i8+20);
        } else if (paramInt3 == 8) {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 10;
            //localTextView.setWidth(i8+20);
        } else if (paramInt3 % 2 == 0) {
            localDrawable = getResources().getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        //int i9 = (int) Math.max(i8, mPaint.measureText(paramString));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    //      if ((paramInt3 == j) && (paramInt4 == l)) {
    //         int i13 = this.residTitleScrollCol[l];
    //         localDrawable = localResources.getDrawable(i13);
    //         localTextView.setTextColor(paramInt1);
    //         localTextView.setBackgroundDrawable(localDrawable);
    //         paramLinearLayout.addView(localTextView);
    //         return;
    //      }
}

From source file:com.github.irshulx.Components.InputExtensions.java

public void UpdateTextStyle(EditorTextStyle style, TextView editText) {
    /// String type = getControlType(getActiveView());
    try {//from   w w  w . j  av  a2  s  .  c o m
        if (editText == null) {
            editText = (EditText) editorCore.getActiveView();
        }
        EditorControl tag = editorCore.getControlTag(editText);

        int pBottom = editText.getPaddingBottom();
        int pRight = editText.getPaddingRight();
        int pTop = editText.getPaddingTop();

        if (isEditorTextStyleHeaders(style)) {
            updateTextStyle(editText, style);
            return;
        }
        if (isEditorTextStyleContentStyles(style)) {
            boolean containsHeadertextStyle = containsHeaderTextStyle(tag);
            if (style == EditorTextStyle.BOLD) {
                boldifyText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT);
            } else if (style == EditorTextStyle.ITALIC) {
                italicizeText(tag, editText, containsHeadertextStyle ? HEADING : CONTENT);
            }
            return;
        }
        if (style == EditorTextStyle.INDENT) {
            if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete);
                editText.setPadding(0, pTop, pRight, pBottom);
                editText.setTag(tag);
            } else {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Insert);
                editText.setPadding(30, pTop, pRight, pBottom);
                editText.setTag(tag);
            }
        } else if (style == EditorTextStyle.OUTDENT) {
            if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.INDENT)) {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.INDENT, Op.Delete);
                editText.setPadding(0, pTop, pRight, pBottom);
                editText.setTag(tag);
            }
        } else if (style == EditorTextStyle.BLOCKQUOTE) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editText.getLayoutParams();
            if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BLOCKQUOTE)) {
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Delete);
                editText.setPadding(0, pTop, pRight, pBottom);
                editText.setBackgroundDrawable(ContextCompat.getDrawable(this.editorCore.getContext(),
                        R.drawable.invisible_edit_text));
                params.setMargins(0, 0, 0, (int) editorCore.getContext().getResources()
                        .getDimension(R.dimen.edittext_margin_bottom));
            } else {
                float marginExtra = editorCore.getContext().getResources()
                        .getDimension(R.dimen.edittext_margin_bottom) * 1.5f;
                tag = editorCore.updateTagStyle(tag, EditorTextStyle.BLOCKQUOTE, Op.Insert);
                editText.setPadding(30, pTop, 30, pBottom);
                editText.setBackgroundDrawable(
                        editText.getContext().getResources().getDrawable(R.drawable.block_quote_background));
                params.setMargins(0, (int) marginExtra, 0, (int) marginExtra);
            }
            editText.setTag(tag);
        }
    } catch (Exception e) {

    }
}

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

public void fillHighlightList() {
    Theme theme = getCurrentTheme();//w w w.  ja v a  2  s  .  c om
    int textColor = theme.foregroundColor;
    this.listView.removeAllViews();
    Highlights highlights = sd.fetchAllHighlights(this.bookCode);
    for (int i = 0; i < highlights.getSize(); i++) {
        Highlight highlight = highlights.getHighlight(i);
        SkyLayout item = new SkyLayout(this);
        int ci = highlight.chapterIndex;
        if (rv.isRTL()) {
            ci = rv.getNumberOfChapters() - ci - 1;
        }
        String chapterTitle = rv.getChapterTitle(ci);
        if (chapterTitle == null || chapterTitle.isEmpty())
            chapterTitle = "Chapter " + ci;

        TextView chapterLabel = this.makeLabel(9899, chapterTitle, Gravity.LEFT, 16, textColor);
        setFrame(chapterLabel, ps(20), ps(5), this.listView.getWidth() - ps(20), ps(40));
        item.addView(chapterLabel);

        GradientDrawable textGrad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { getBrighterColor(highlight.color), getDarkerColor(highlight.color) });
        TextView textLabel = this.makeLabel(9899, highlight.text, Gravity.LEFT, 16, Color.BLACK);
        setFrame(textLabel, ps(20), ps(5 + 40 + 5), this.listView.getWidth() - ps(20), ps(70));
        textLabel.setBackgroundDrawable(textGrad);
        textLabel.getBackground().setAlpha(180);

        item.addView(textLabel);

        int noteHeight = 0;

        if (highlight.isNote && highlight.note != null && highlight.note.length() != 0
                && !highlight.note.equalsIgnoreCase("null")) {
            TextView noteLabel = this.makeLabel(9899, highlight.note, Gravity.LEFT, 16, Color.BLACK);
            noteLabel.setTextColor(getDarkerColor(highlight.color));
            noteHeight = 70;
            setFrame(noteLabel, ps(20), ps(5 + 40 + 5 + 70 + 5), this.listView.getWidth() - ps(20),
                    ps(noteHeight));
            item.addView(noteLabel);
        }

        TextView dateLabel = this.makeLabel(9899, highlight.datetime, Gravity.RIGHT, 12, textColor);
        int lw = this.listView.getWidth();
        setFrame(dateLabel, 0, ps(5 + 40 + 5 + 70 + 5 + noteHeight + 5), lw, ps(40));
        item.addView(dateLabel);

        int itemHeight = ps(5 + 40 + 5 + 90 + 5 + noteHeight + 5 + 15 + 5);

        View lineView = new View(this);
        lineView.setBackgroundColor(Color.LTGRAY);
        setFrame(lineView, 0, itemHeight - ps(1), this.listView.getWidth(), ps(1));
        item.addView(lineView);

        setFrame(item, 0, 0, listView.getWidth(), itemHeight);
        item.setSkyLayoutListener(highlightListDelegate);
        item.setId(highlight.code);
        item.data = highlight;

        Button deleteButton = new Button(this);
        GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM,
                new int[] { 0xffcf666e, 0xff671521 });
        grad.setStroke(ps(2), 0xff282828);
        deleteButton.setBackgroundDrawable(grad);
        deleteButton.setText(getString(R.string.delete));
        deleteButton.setTypeface(null, Typeface.BOLD);
        deleteButton.setTextColor(Color.WHITE);
        deleteButton.setTextSize(12);
        deleteButton.setId(highlight.code);
        deleteButton.setVisibility(View.INVISIBLE);
        deleteButton.setVisibility(View.GONE);
        deleteButton.setOnClickListener(deleteHighlightDelegate);
        int dw = ps(120);
        int dh = ps(50);
        setFrame(deleteButton, this.listView.getWidth() - dw, (itemHeight - dh) / 2, dw, dh);
        item.deleteControl = deleteButton;
        item.addView(deleteButton);

        this.listView.addView(item);
    }
}