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


Java TextView.getMeasuredHeight方法代碼示例

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


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

示例1: createLabelBitmap

import android.widget.TextView; //導入方法依賴的package包/類
public Bitmap createLabelBitmap(String label) {
       if (DBG) Log.d(TAG, "createLabelBitmap : label="+ label);

       mLabelView = (TextView)mLayoutInflater.inflate(R.layout.cover_roll_label, null);
	mLabelView.setText(label);
	mLabelView.setLayoutParams( new FrameLayout.LayoutParams(NO_SIZE_LIMIT,NO_SIZE_LIMIT) );
	mLabelView.measure(NO_SIZE_LIMIT, NO_SIZE_LIMIT);
	final int width = mLabelView.getMeasuredWidth();
	final int height = mLabelView.getMeasuredHeight();
	if(DBG) Log.d(TAG, "createLabelBitmap: mLabelView size = "+width+"x"+height);
	mLabelView.layout(0, 0, width, height);

       StaticLayout textLayout = null;
       if (isRtlLabel()) {
           // Archos hack : when a right-to-left language is selected calling TextView.draw()
           // draws the background but not the text, so also call TextLayout.draw() which works
           textLayout = createTextLayout(label, Color.LTGRAY, mContentLabelFontsize, width);
       }
       return createViewBitmap(mLabelView, textLayout, width, height, ALIGN_BOTTOM);
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:21,代碼來源:ArtworkFactory.java

示例2: getHeight

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 在繪製之前,測量 TextView 的高度
 * @param context  上下文
 * @param text 內容
 * @param textSize sp
 * @param deviceWidth TextView 所在容器的寬度[重要]
 * @param typeface 加粗等等樣式
 * @param padding 內間距
 * @return TextView 的高度
 */
public int getHeight(Context context, CharSequence text, int textSize, int deviceWidth, Typeface typeface, int padding) {
    TextView textView = new TextView(context);
    textView.setPadding(padding,padding,padding,padding);
    textView.setTypeface(typeface);
    textView.setText(text, TextView.BufferType.SPANNABLE);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(deviceWidth, View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(widthMeasureSpec, heightMeasureSpec);
    return textView.getMeasuredHeight();
}
 
開發者ID:didikee,項目名稱:cnBetaGeek,代碼行數:22,代碼來源:CommentsView.java

示例3: getShortHeight

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 要伸縮文本的高度 寬度固定的MeasureSpec.EXACTLY 高度MeasureSpec.AT_MOST
 *
 * @return
 */
public int getShortHeight() {
    int measuredWidth = contentTextView.getMeasuredWidth();
    TextView copyTextView = new TextView(getContext());
    copyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 8);
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY);
    copyTextView.setMaxLines(3);//設置默認不展開的情況下顯示3行
    copyTextView.setLines(3);//文本設置3行 不夠3行顯示3行的高度
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(2000, MeasureSpec.AT_MOST);
    copyTextView.measure(widthMeasureSpec, heightMeasureSpec);
    return copyTextView.getMeasuredHeight();
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:17,代碼來源:FoldingTextView.java

示例4: getTileHeight

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Title的高度(更新 應用介紹 權限 這幾個字) 寬度是固定的MeasureSpec.EXACTLY
 *
 * @return
 */
public int getTileHeight() {
    int measuredWidth = titleTextView.getMeasuredWidth();
    TextView copyTextView = new TextView(getContext());
    copyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY);
    copyTextView.setMaxLines(1);
    copyTextView.setLines(1);
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(2000, MeasureSpec.AT_MOST);//MeasureSpec.AT_MOST情況下前一個參數設置多少無所謂
    copyTextView.measure(widthMeasureSpec, heightMeasureSpec);
    return copyTextView.getMeasuredHeight();
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:17,代碼來源:FoldingTextView.java

示例5: getHeight

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 獲取TextView的高度
 * @param context
 * @param text
 * @param textSize
 * @param deviceWidth
 * @param typeface
 * @param padding
 * @return
 */
public static int getHeight(Context context, CharSequence text, int textSize, int deviceWidth, Typeface typeface, int padding) {
    TextView textView = new TextView(context);
    textView.setPadding(padding,0,padding,padding);
    textView.setTypeface(typeface);
    textView.setText(text, TextView.BufferType.SPANNABLE);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(deviceWidth, View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(widthMeasureSpec, heightMeasureSpec);
    return textView.getMeasuredHeight();
}
 
開發者ID:Break369,項目名稱:MyLife,代碼行數:22,代碼來源:TextViewUtils.java

示例6: measureTextViewHeight

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 獲取文本實際所占高度,輔助用於計算行高,行數
 *
 * @param text        文本
 * @param textSize    字體大小
 * @param deviceWidth 屏幕寬度
 */
private void measureTextViewHeight(String text, float textSize, int deviceWidth) {
    TextView textView = new TextView(getContext());
    textView.setText(text);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(deviceWidth, MeasureSpec.EXACTLY);
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    textView.measure(widthMeasureSpec, heightMeasureSpec);
    originalLineCount = textView.getLineCount();
    originalHeight = textView.getMeasuredHeight();
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:18,代碼來源:AlignTextView.java

示例7: MeasureString

import android.widget.TextView; //導入方法依賴的package包/類
public static Point MeasureString(Context context, String text, float fontSize, int widthMeasureSpec, int heightMeasureSpec) {
    int width = 0;
    int height = 0;

    if (null == context || null == text || text.isEmpty() || 0 == fontSize) {
        return null;
    }

    TextView tv = new TextView(context);

    tv.setText(text);// 待測文本
    tv.setTextSize(fontSize);// 字體

    if (ViewGroup.LayoutParams.WRAP_CONTENT != widthMeasureSpec && ViewGroup.LayoutParams.MATCH_PARENT != widthMeasureSpec) {
        tv.setWidth(widthMeasureSpec);// 如果設置了寬度,字符串的寬度則為所設置的寬度
    }

    if (ViewGroup.LayoutParams.WRAP_CONTENT != heightMeasureSpec && ViewGroup.LayoutParams.MATCH_PARENT != heightMeasureSpec) {
        tv.setHeight(heightMeasureSpec);
    }

    tv.setSingleLine(false);// 多行

    tv.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);

    width = tv.getMeasuredWidth();
    height = tv.getMeasuredHeight();

    Point point = new Point();
    point.x = width;
    point.y = height;

    return point;
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:35,代碼來源:Utils.java

示例8: setTvWrapHeight

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 在某些特定場合下; TextView 的 wrap_content 屬性不生效;隻好手動設置
 * @param textView
 * @param tvWidth textView 在屏幕上顯示的寬(也就是 textView 父容器賜予的最大寬)
 */
public static void setTvWrapHeight(TextView textView,int tvWidth){
    textView.measure(0,0);
    int height = textView.getMeasuredHeight();
    ViewGroup.LayoutParams params = textView.getLayoutParams();
    params.height = height * getRow(textView, tvWidth) ;
    textView.setLayoutParams(params);
}
 
開發者ID:42Chapters,項目名稱:AdaptationX-android,代碼行數:13,代碼來源:TextViewManager.java

示例9: layoutDebugInfo

import android.widget.TextView; //導入方法依賴的package包/類
private void layoutDebugInfo(final int positionInStrip, final ViewGroup placerView,
        final int x) {
    final TextView debugInfoView = mDebugInfoViews.get(positionInStrip);
    final CharSequence debugInfo = debugInfoView.getText();
    if (debugInfo == null) {
        return;
    }
    placerView.addView(debugInfoView);
    debugInfoView.measure(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int infoWidth = debugInfoView.getMeasuredWidth();
    final int y = debugInfoView.getMeasuredHeight();
    ViewLayoutUtils.placeViewAt(
            debugInfoView, x - infoWidth, y, infoWidth, debugInfoView.getMeasuredHeight());
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:16,代碼來源:SuggestionStripLayoutHelper.java

示例10: getTextViewHeight

import android.widget.TextView; //導入方法依賴的package包/類
private static int getTextViewHeight(TextView textView, int width) {
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(widthMeasureSpec, heightMeasureSpec);
    return textView.getMeasuredHeight();
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:7,代碼來源:GoodView.java


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