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


Java TextView.getHeight方法代碼示例

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


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

示例1: updateTitleBottomPadding

import android.widget.TextView; //導入方法依賴的package包/類
private void updateTitleBottomPadding() {
    if (tabContainer == null) {
        return;
    }

    int childCount = getTabCount();

    for (int i = 0; i < childCount; i++) {
        View tab = tabContainer.getChildAt(i);
        TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title);

        if (title == null) {
            continue;
        }

        int baseline = title.getBaseline();
        int height = title.getHeight();
        int paddingInsideTitle = height - baseline;
        int missingPadding = tenDp - paddingInsideTitle;

        if (missingPadding > 0) {
            title.setPadding(title.getPaddingLeft(), title.getPaddingTop(),
                    title.getPaddingRight(), missingPadding + title.getPaddingBottom());
        }
    }
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:27,代碼來源:BottomBar.java

示例2: CsDrawableTouchUtils

import android.widget.TextView; //導入方法依賴的package包/類
CsDrawableTouchUtils(MotionEvent event, TextView view, boolean isLayoutRTL){
    this.event = event;
    this.view = view;
    this.isLayoutRTL = isLayoutRTL;
    vSpace = view.getHeight() - view.getCompoundPaddingBottom() - view.getCompoundPaddingTop();
    hSpace = view.getWidth() - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    //if the drawable is extremely large (pushing the edges of the drawable itself
    //or of the other drawables out of the current view bounds, will not be possible
    //to calculate the correct touch position
    if (hSpace < 0 || vSpace < 0){
        throw new IllegalArgumentException("The size of one of your drawable is exceeding the" +
                " calculated width or height of the view. In this case you should provide" +
                "a smaller drawable or provide a smaller dimension in XML or with the builder");
    }
    scrollX = view.getScrollX();
    scrollY = view.getScrollY();
}
 
開發者ID:matpag,項目名稱:ClickDrawableTextView,代碼行數:18,代碼來源:CsDrawableTouchUtils.java

示例3: onNestedPreScroll

import android.widget.TextView; //導入方法依賴的package包/類
@Override
public void onNestedPreScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull TextView child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) {
    super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
    if (target instanceof RecyclerView) {
        RecyclerView list = (RecyclerView) target;
        //列表第一個全部可見Item的位置
        int pos = ((LinearLayoutManager) list.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
        if (pos == 0 && pos < lastPosition) {
            downReach = true;
        }

        if (canScroll(child, dy) && pos == 0) {
            float finalY = child.getTranslationY() - dy;
            if (finalY < -child.getHeight()) {
                finalY = -child.getHeight();
                upReach = true;
            } else if (finalY > 0) {
                finalY = 0;
            }
            child.setTranslationY(finalY);
            consumed[1] = dy;
        }
        lastPosition = pos;
    }
}
 
開發者ID:Othershe,項目名稱:BehaviorDemo,代碼行數:26,代碼來源:SampleHeaderBehavior.java

示例4: captureTextBitmap

import android.widget.TextView; //導入方法依賴的package包/類
private static Bitmap captureTextBitmap(TextView textView) {
    Drawable background = textView.getBackground();
    textView.setBackground(null);
    int width = textView.getWidth() - textView.getPaddingLeft() - textView.getPaddingRight();
    int height = textView.getHeight() - textView.getPaddingTop() - textView.getPaddingBottom();
    if (width == 0 || height == 0) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.translate(-textView.getPaddingLeft(), -textView.getPaddingTop());
    textView.draw(canvas);
    textView.setBackground(background);
    return bitmap;
}
 
開發者ID:googlesamples,項目名稱:android-instant-apps,代碼行數:16,代碼來源:TextResize.java

示例5: TextResizeData

import android.widget.TextView; //導入方法依賴的package包/類
public TextResizeData(TextView textView) {
    this.paddingLeft = textView.getPaddingLeft();
    this.paddingTop = textView.getPaddingTop();
    this.paddingRight = textView.getPaddingRight();
    this.paddingBottom = textView.getPaddingBottom();
    this.width = textView.getWidth();
    this.height = textView.getHeight();
    this.gravity = textView.getGravity();
    this.textColor = textView.getCurrentTextColor();
}
 
開發者ID:googlesamples,項目名稱:android-instant-apps,代碼行數:11,代碼來源:TextResize.java

示例6: getRealHeight

import android.widget.TextView; //導入方法依賴的package包/類
private int getRealHeight() {
    TextView tv = textViewWeakReference.get();
    if (tv == null) {
        return 0;
    }
    return tv.getHeight() - tv.getPaddingTop() - tv.getPaddingBottom();
}
 
開發者ID:nichbar,項目名稱:Aequorea,代碼行數:8,代碼來源:AbstractImageLoader.java

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