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