当前位置: 首页>>代码示例>>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;未经允许,请勿转载。