v.setMaxEms(a.getInt(attr, -1));
public void run(RapidParserObject object, Object view, Var value) { ((TextView)view).setMaxEms(value.getInt()); } }
@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); }
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); }
@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); } }
@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); } }
tv.setSingleLine(); tv.setEllipsize(TextUtils.TruncateAt.END); tv.setMaxEms(6);//限制4个字符
@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)); } }
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);
@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(); } }
textView.setMaxEms(attributes.getInt("maxEms"));
Utils.setBackground(bubbleView, getResources().getDrawable(R.drawable.balloon_overlay_unfocused)); bubbleView.setGravity(Gravity.CENTER); bubbleView.setMaxEms(20); bubbleView.setTextSize(15); bubbleView.setTextColor(Color.BLACK);