android.widget.TextView.setMaxEms()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(293)

本文整理了Java中android.widget.TextView.setMaxEms()方法的一些代码示例,展示了TextView.setMaxEms()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setMaxEms()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setMaxEms

TextView.setMaxEms介绍

暂无

代码示例

代码示例来源:origin: rey5137/material

v.setMaxEms(a.getInt(attr, -1));

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    ((TextView)view).setMaxEms(value.getInt());
  }
}

代码示例来源:origin: SharryChoo/SToolbar

@Override
public void completion(TextView textView) {
  // Set padding.
  textView.setPadding(paddingLeft, 0, paddingRight, 0);
  ViewGroup.LayoutParams params = textView.getLayoutParams();
  if (null == params) {
    params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
  } else {
    params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
  }
  textView.setLayoutParams(params);
  // Set OnClickListener
  if (null != listener) {
    textView.setOnClickListener(listener);
  }
  // Set some fields associated with this textView.
  textView.setText(text);
  textView.setTextColor(textColor);
  textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
  textView.setMaxEms(maxEms);
  textView.setLines(lines);
  textView.setEllipsize(ellipsize);
}

代码示例来源:origin: mapsforge/mapsforge

public static Bitmap getBitmapFromTitle(String title, Paint paint) {
  if (!captionViews.containsKey(title)) {
    TextView bubbleView = new TextView(context);
    Utils.setBackground(bubbleView, context.getResources().getDrawable(R.drawable.caption_background));
    bubbleView.setGravity(Gravity.CENTER);
    bubbleView.setMaxEms(20);
    bubbleView.setTextSize(10);
    bubbleView.setPadding(5, -2, 5, -2);
    bubbleView.setTextColor(android.graphics.Color.BLACK);
    bubbleView.setText(title);
    //Measure the view at the exact dimensions (otherwise the text won't center correctly)
    int widthSpec = View.MeasureSpec.makeMeasureSpec(paint.getTextWidth(title), View.MeasureSpec.EXACTLY);
    int heightSpec = View.MeasureSpec.makeMeasureSpec(paint.getTextHeight(title), View.MeasureSpec.EXACTLY);
    bubbleView.measure(widthSpec, heightSpec);
    //Layout the view at the width and height
    bubbleView.layout(0, 0, paint.getTextWidth(title), paint.getTextHeight(title));
    captionViews.put(title, Utils.viewToBitmap(context, bubbleView));
    captionViews.get(title).incrementRefCount(); // FIXME: is never reduced!
  }
  return captionViews.get(title);
}

代码示例来源:origin: dc297/mqttclpro

@Override
  public BindingHolder<TopicListItemBinding> onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater  = LayoutInflater.from(parent.getContext());
    final TopicListItemBinding binding = TopicListItemBinding.inflate(inflater, parent, false);
    binding.getRoot().setTag(binding);
    binding.getRoot().setOnClickListener(this);
    binding.getRoot().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
      @Override
      public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.delete_subscribe_topic_menu, menu);
        toDelete = (TopicEntity) binding.getTopic();
      }
    });
    TextView topicTV = (TextView) binding.getRoot().findViewById(R.id.topic_tv);
    if(getApplication().getResources().getConfiguration().orientation== Configuration.ORIENTATION_LANDSCAPE) topicTV.setMaxEms(20);
    else topicTV.setMaxEms(8);
    topicTV.setSelected(true);
    return new BindingHolder<>(binding);
  }
}

代码示例来源:origin: dc297/mqttclpro

@Override
  public BindingHolder<TopicListItemBinding> onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater  = LayoutInflater.from(parent.getContext());
    final TopicListItemBinding binding = TopicListItemBinding.inflate(inflater, parent, false);
    binding.getRoot().setTag(binding);
    binding.getRoot().setOnClickListener(this);
    binding.getRoot().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
      @Override
      public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.subscribe_topic_menu, menu);
        toDelete = (TopicEntity) binding.getTopic();
      }
    });
    TextView topicTV = (TextView) binding.getRoot().findViewById(R.id.topic_tv);
    if(getApplication().getResources().getConfiguration().orientation== Configuration.ORIENTATION_LANDSCAPE) topicTV.setMaxEms(20);
    else topicTV.setMaxEms(8);
    topicTV.setSelected(true);
    return new BindingHolder<>(binding);
  }
}

代码示例来源:origin: 66668/DropDownMenuplus

tv.setSingleLine();
tv.setEllipsize(TextUtils.TruncateAt.END);
tv.setMaxEms(6);//限制4个字符

代码示例来源:origin: mapsforge/mapsforge

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void createLayers() {
  super.createLayers();
  // Bubble overlays
  for (DummyContent.DummyItem item : DummyContent.ITEMS) {
    TextView bubbleView = new TextView(this);
    Utils.setBackground(bubbleView, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDrawable(R.drawable.balloon_overlay_unfocused) : getResources().getDrawable(R.drawable.balloon_overlay_unfocused));
    bubbleView.setGravity(Gravity.CENTER);
    bubbleView.setMaxEms(20);
    bubbleView.setTextSize(15);
    bubbleView.setTextColor(Color.BLACK);
    bubbleView.setText(item.text);
    bubble = Utils.viewToBitmap(this, bubbleView);
    bubble.incrementRefCount();
    this.mapView.getLayerManager().getLayers().add(new Marker(item.location, bubble, 0, -bubble.getHeight() / 2));
  }
}

代码示例来源:origin: huangfangyi/YiChat

if (chatType == ChatType.groupChat) {
  holder.tv_name.setMaxLines(1);
  holder.tv_name.setMaxEms(10);
  holder.tv_name.setEllipsize(TextUtils.TruncateAt.END);
  HTGroup htGroup = HTClient.getInstance().groupManager().getGroup(userId);

代码示例来源:origin: sytolk/TaxiAndroidOpen

@UiThread
void showCarPosition(Cars cars) {
  if (TaxiApplication.isMapVisible() && cars != null) {
    //final List<Layer> overlayItems = carsOverlay.getOverlayItems();
    //overlayItems.clear();
    TextView bubbleView = new TextView(this);
    Utils.setBackground(bubbleView, getResources().getDrawable(R.drawable.balloon_overlay_unfocused));
    bubbleView.setGravity(Gravity.CENTER);
    bubbleView.setMaxEms(20);
    bubbleView.setTextSize(15);
    bubbleView.setTextColor(Color.BLACK);
    bubbleView.setText(cars.getNumber());
    bubble = Utils.viewToBitmap(this, bubbleView);
    bubble.incrementRefCount();
    if (cars.getCurrPosNorth() != null && cars.getCurrPosEast() != null) {
      Marker marker = new Marker(new LatLong(cars.getCurrPosNorth(), cars.getCurrPosEast()), bubble, 0, -bubble.getHeight() / 2);
      //marker.setDisplayModel(this.mapViews.get(0).getModel().displayModel);
      carsOverlay.add(marker);
      mapView.getLayerManager().getLayers().add(marker);
      //Log.i(TAG, "Car:" + cars.getNumber());
    }
    //carsOverlay.requestRedraw();
  }
}

代码示例来源:origin: jelic98/dynamico

textView.setMaxEms(attributes.getInt("maxEms"));

代码示例来源:origin: sytolk/TaxiAndroidOpen

Utils.setBackground(bubbleView, getResources().getDrawable(R.drawable.balloon_overlay_unfocused));
bubbleView.setGravity(Gravity.CENTER);
bubbleView.setMaxEms(20);
bubbleView.setTextSize(15);
bubbleView.setTextColor(Color.BLACK);

相关文章

TextView类方法