當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.getTotalPaddingBottom方法代碼示例

本文整理匯總了Java中android.widget.TextView.getTotalPaddingBottom方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.getTotalPaddingBottom方法的具體用法?Java TextView.getTotalPaddingBottom怎麽用?Java TextView.getTotalPaddingBottom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.getTotalPaddingBottom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: action

import android.widget.TextView; //導入方法依賴的package包/類
private boolean action(int what, TextView widget, Spannable buffer) {
    Layout layout = widget.getLayout();
    int padding = widget.getTotalPaddingTop() + widget.getTotalPaddingBottom();
    int areatop = widget.getScrollY();
    int areabot = (widget.getHeight() + areatop) - padding;
    int linetop = layout.getLineForVertical(areatop);
    int linebot = layout.getLineForVertical(areabot);
    int first = layout.getLineStart(linetop);
    int last = layout.getLineEnd(linebot);
    MyURLSpan[] candidates = (MyURLSpan[]) buffer.getSpans(first, last, MyURLSpan.class);
    int a = Selection.getSelectionStart(buffer);
    int b = Selection.getSelectionEnd(buffer);
    int selStart = Math.min(a, b);
    int selEnd = Math.max(a, b);
    if (selStart < 0 && buffer.getSpanStart(FROM_BELOW) >= 0) {
        selEnd = buffer.length();
        selStart = selEnd;
    }
    if (selStart > last) {
        selEnd = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
        selStart = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
    }
    if (selEnd < first) {
        selEnd = -1;
        selStart = -1;
    }
    int beststart;
    int bestend;
    int i;
    switch (what) {
        case 1:
            if (selStart != selEnd) {
                MyURLSpan[] link = (MyURLSpan[]) buffer.getSpans(selStart, selEnd, MyURLSpan
                        .class);
                if (link.length == 1) {
                    link[0].onClick(widget);
                    break;
                }
                return false;
            }
            return false;
        case 2:
            beststart = -1;
            bestend = -1;
            for (i = 0; i < candidates.length; i++) {
                int end = buffer.getSpanEnd(candidates[i]);
                if ((end < selEnd || selStart == selEnd) && end > bestend) {
                    beststart = buffer.getSpanStart(candidates[i]);
                    bestend = end;
                }
            }
            if (beststart >= 0) {
                Selection.setSelection(buffer, bestend, beststart);
                return true;
            }
            break;
        case 3:
            beststart = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
            bestend = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
            for (i = 0; i < candidates.length; i++) {
                int start = buffer.getSpanStart(candidates[i]);
                if ((start > selStart || selStart == selEnd) && start < beststart) {
                    beststart = start;
                    bestend = buffer.getSpanEnd(candidates[i]);
                }
            }
            if (bestend < Integer.MAX_VALUE) {
                Selection.setSelection(buffer, beststart, bestend);
                return true;
            }
            break;
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:75,代碼來源:LongClickableLinkMovementMethod.java


注:本文中的android.widget.TextView.getTotalPaddingBottom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。