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


Java TextView.getPaint方法代碼示例

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


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

示例1: addTab

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 添加指示器
 *
 * @param position
 * @param title
 */
private void addTab(final int position, CharSequence title) {
    TextView tvTab = new TextView(context);
    tvTab.setText(title);
    tvTab.setTextColor(textColor);
    tvTab.setTextSize(textSize);
    tvTab.setGravity(Gravity.CENTER);
    if(isIndicatorTextBold){
        TextPaint tp = tvTab.getPaint();
        tp.setFakeBoldText(true);
    }
    tvTab.setSingleLine();
    tvTab.setFocusable(true);
    tvTab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewPager.setCurrentItem(position);
        }
    });
    tvTab.setPadding(indicatorMargin, 0, indicatorMargin, 0);
    container.addView(tvTab, position, expandedTabLayoutParams);
}
 
開發者ID:xfangfang,項目名稱:NeuTV,代碼行數:28,代碼來源:TabStrip.java

示例2: measureTabLayoutTextWidth

import android.widget.TextView; //導入方法依賴的package包/類
private void measureTabLayoutTextWidth(int position) {

        String title = titles.get(position);
        TextView titleView = mSlidingTabLayout.getTitleView(position);
        TextPaint paint = titleView.getPaint();
        float textWidth = paint.measureText(title);
        mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
    }
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:9,代碼來源:VideoDetailsActivity.java

示例3: measureTabLayoutTextWidth

import android.widget.TextView; //導入方法依賴的package包/類
public void measureTabLayoutTextWidth(int position) {

    String titleName = titles.get(position);
    TextView titleView = mSlidingTab.getTitleView(position);
    TextPaint paint = titleView.getPaint();
    float v = paint.measureText(titleName);
    mSlidingTab.setIndicatorWidth(v / 3);
  }
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:9,代碼來源:RegionTypeDetailsActivity.java

示例4: measureTabLayoutTextWidth

import android.widget.TextView; //導入方法依賴的package包/類
private void measureTabLayoutTextWidth(int position) {

    String title = titles.get(position);
    TextView titleView = mSlidingTabLayout.getTitleView(position);
    TextPaint paint = titleView.getPaint();
    float textWidth = paint.measureText(title);
    mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
  }
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:9,代碼來源:TotalStationSearchActivity.java

示例5: measureTabLayoutTextWidth

import android.widget.TextView; //導入方法依賴的package包/類
private void measureTabLayoutTextWidth(int position) {
    String title = mTitles.get(position);
    TextView titleView = mSlidingTab.getTitleView(position);
    TextPaint paint = titleView.getPaint();
    float width = paint.measureText(title);
    mSlidingTab.setIndicatorWidth(width / 3);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:8,代碼來源:RegionTypeDetailsActivity.java

示例6: measureTabLayoutTextWidth

import android.widget.TextView; //導入方法依賴的package包/類
private void measureTabLayoutTextWidth(int position) {
    String title = mTitles.get(position);
    TextView titleView = mSlidingTabLayout.getTitleView(position);
    TextPaint paint = titleView.getPaint();
    float textWidth = paint.measureText(title);
    mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:8,代碼來源:VideoDetailsActivity.java

示例7: getStringWidth

import android.widget.TextView; //導入方法依賴的package包/類
public static int getStringWidth(TextView tv, String text) {
    Rect bounds = new Rect();
    TextPaint paint;

    paint = tv.getPaint();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int width = bounds.width();

    return width;
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:11,代碼來源:StringUtils.java

示例8: computeMinWidthRequiredForValues

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Computes and records the minimum width required to display any of the values without
 * causing another layout pass when switching values.
 */
int computeMinWidthRequiredForValues() {
    DualControlLayout layout = getView(0, null, null);
    TextView container = (TextView) layout.getChildAt(1);

    Paint textPaint = container.getPaint();
    float longestLanguageWidth = 0;
    for (int i = 0; i < getCount(); i++) {
        float width = textPaint.measureText(getItem(i).toString());
        longestLanguageWidth = Math.max(longestLanguageWidth, width);
    }

    mMinWidthRequiredForValues = (int) Math.ceil(longestLanguageWidth);
    return mMinWidthRequiredForValues;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:19,代碼來源:InfoBarControlLayout.java

示例9: isOverFlowed

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 判斷TextView的內容寬度是否超出其可用寬度
 *
 * @param tv
 * @return
 */
public static boolean isOverFlowed(TextView tv, int maxWidth) {
    int availableWidth = maxWidth - tv.getPaddingLeft() - tv.getPaddingRight();
    Paint textViewPaint = tv.getPaint();
    float textWidth = textViewPaint.measureText(tv.getText().toString());
    if (textWidth > availableWidth) {
        return true;
    } else {
        return false;
    }
}
 
開發者ID:CardInfoLink,項目名稱:QRScanner,代碼行數:17,代碼來源:SystemUtils.java

示例10: getRow

import android.widget.TextView; //導入方法依賴的package包/類
/**
 *返回 TextView 裏麵 String 所占的行數
 * @param textView
 * @param tvWidth textView 在屏幕上顯示的寬(也就是 textView 父容器賜予的最大寬)
 * @return 行數
 */
public static int getRow(TextView textView,int tvWidth){
    TextPaint paint = textView.getPaint();
    float len = paint.measureText(textView.getText().toString());
    // 行數 = textWidth/控件顯示在屏幕上的寬(父容器允許的最大寬度) ;
    int width = tvWidth - textView.getPaddingLeft() - textView.getPaddingRight();// 需要去掉每一行的 padding 值
    return (int)Math.ceil(len/width);
}
 
開發者ID:42Chapters,項目名稱:AdaptationX-android,代碼行數:14,代碼來源:TextViewManager.java

示例11: getTextWidth

import android.widget.TextView; //導入方法依賴的package包/類
private int getTextWidth(TextView textView) {
    if (textView == null) {
        return 0;
    }
    Rect bounds = new Rect();
    String text = textView.getText().toString();
    Paint paint = textView.getPaint();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int width = bounds.left + bounds.width();
    return width;
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:12,代碼來源:ClassifyAdapter.java

示例12: resizeText

import android.widget.TextView; //導入方法依賴的package包/類
public static void resizeText(TextView textView, int originalTextSize, int minTextSize) {
  final Paint paint = textView.getPaint();
  final int width = textView.getWidth();
  if (width == 0) {
    return;
  }
  textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, originalTextSize);
  float ratio = width / paint.measureText(textView.getText().toString());
  if (ratio <= 1.0f) {
    textView.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, Math.max(minTextSize, originalTextSize * ratio));
  }
}
 
開發者ID:dialogs,項目名稱:android-dialer,代碼行數:14,代碼來源:ViewUtil.java

示例13: setBold

import android.widget.TextView; //導入方法依賴的package包/類
public static void setBold(TextView textView) {
    if (textView != null) {
        TextPaint paint = textView.getPaint();
        paint.setFakeBoldText(true);
    }
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:7,代碼來源:StyleHelper.java

示例14: setFakeBold

import android.widget.TextView; //導入方法依賴的package包/類
public static void setFakeBold(TextView textView, boolean isBold)
{
    TextPaint tp = textView.getPaint();
    tp.setFakeBoldText(isBold);
}
 
開發者ID:zhuyu1022,項目名稱:amap,代碼行數:6,代碼來源:MIP_TextStyle.java

示例15: onCreate

import android.widget.TextView; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Retrieve the content view that renders the map.
        setContentView(R.layout.activity_maps);
        // Add title
        getSupportActionBar().setTitle("Event Details");
        // Add Back button
        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        if(actionBar != null){
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        // Get intent
        Intent intename = getIntent();
//        nameString = (String) intename.getSerializableExtra("NAME");
//        timeString = (String) intename.getSerializableExtra("TIME");
        nameString = "lalala";
        timeString = "24:00";
        descriptionString = (String) intename.getSerializableExtra("PostText");
        lat = (double) intename.getSerializableExtra("LAT");
        lng = (double) intename.getSerializableExtra("LNG");
//        zipcodeString = (String) intename.getSerializableExtra("ZIPCODE");
//        addressString = (String) intename.getSerializableExtra("ADDRESS");
        zipcodeString = "02215";
        addressString = "PHO";
        location = new LatLng(lat, lng);
        // Get the SupportMapFragment and request notification
        // when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
        // Get TextView
        name = (TextView) findViewById(R.id.Name);
        time = (TextView) findViewById(R.id.Time);
        description = (TextView) findViewById(R.id.Description);
        // Get Button
        mapAppCtrl = (Button) findViewById(R.id.openMap);
        mapAppCtrl.setOnClickListener(new MapsMarkerActivity.ButtonClickHandler());
        // Set TextView uneditable
        name.setKeyListener(null);
        time.setKeyListener(null);
        description.setKeyListener(null);
        // Set TextView size and bold
        name.setTextSize(20);
        time.setTextSize(10);
        TextPaint paint = name.getPaint();
        paint.setFakeBoldText(true);
        //Set content
        name.setText(nameString);
        time.setText(timeString);
        description.setText(String.format("%s\n%s\n%s", descriptionString, addressString, zipcodeString));
    }
 
開發者ID:kev5,項目名稱:GoMeet,代碼行數:54,代碼來源:MapsMarkerActivity.java


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