List of usage examples for android.widget TextView setMaxEms
@android.view.RemotableViewMethod public void setMaxEms(int maxEms)
From source file:org.voidsink.anewjkuapp.fragment.MapFragment.java
private void setNewGoal(LatLong goalPosition, String name) { if (goalPosition != null && mMyLocationOverlay != null && goalLocationOverlay != null) { this.mMyLocationOverlay.setSnapToLocationEnabled(false); if (!name.isEmpty()) { // generate Bubble image TextView bubbleView = new TextView(this.getContext()); MapUtils.setBackground(bubbleView, getResources().getDrawable(R.drawable.balloon_overlay)); bubbleView.setGravity(Gravity.CENTER); bubbleView.setMaxEms(20); bubbleView.setTextSize(15);//from w ww. j a v a 2 s.co m bubbleView.setTextColor(Color.BLACK); bubbleView.setText(name); Bitmap bubble = MapUtils.viewToBitmap(getContext(), bubbleView); bubble.incrementRefCount(); // set new goal this.goalLocationOverlay.setLatLong(goalPosition); this.goalLocationOverlay.setBitmap(bubble); this.goalLocationOverlay.setHorizontalOffset(0); this.goalLocationOverlay.setVerticalOffset(-bubble.getHeight() / 2); } else { Drawable d = getResources().getDrawable(R.drawable.ic_marker_goal_position); Bitmap b = AndroidGraphicFactory.convertToBitmap(d); // set new goal this.goalLocationOverlay.setLatLong(goalPosition); this.goalLocationOverlay.setBitmap(b); this.goalLocationOverlay.setHorizontalOffset(0); this.goalLocationOverlay.setVerticalOffset(0); } if (this.mMyLocationOverlay != null && this.mMyLocationOverlay.getLastLocation() != null) { LatLong mLocation = LocationOverlay.locationToLatLong(this.mMyLocationOverlay.getLastLocation()); // lat long difference for bounding box double mDLat = Math.abs((mLocation.latitude - goalPosition.latitude)); double mDLong = Math.abs((mLocation.longitude - goalPosition.longitude)); // trunc distance double distance = mLocation.distance(goalPosition); if (distance > 0.0088) { mDLat = (mDLat * 0.0088 / distance); mDLong = (mDLong * 0.0088 / distance); } // zoom to bounds BoundingBox bb = new BoundingBox( Math.max(MercatorProjection.LATITUDE_MIN, goalPosition.latitude - mDLat), Math.max(-180, goalPosition.longitude - mDLong), Math.min(MercatorProjection.LATITUDE_MAX, goalPosition.latitude + mDLat), Math.min(180, goalPosition.longitude + mDLong)); Dimension dimension = this.mapView.getModel().mapViewDimension.getDimension(); // zoom to bounding box, center at goalPosition this.mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(goalPosition, LatLongUtils .zoomForBounds(dimension, bb, this.mapView.getModel().displayModel.getTileSize()))); } else { this.mapViewPosition.setCenter(goalPosition); } } else { this.goalLocationOverlay.setLatLong(null); this.mMyLocationOverlay.setSnapToLocationEnabled(true); } this.goalLocationOverlay.requestRedraw(); this.mMyLocationOverlay.requestRedraw(); }
From source file:net.gnu.common.view.SlidingHorizontalScroll.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); final int count = adapter.getCount(); for (int i = 0; i < count; i++) { View tabView = null;/*from w w w . j ava2 s . c om*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStripLinearLayout, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if ((fra == null || fra.circular()) && (i == 0 || i == count - 1) && count > 1) { final int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); tabView.setPadding(0, padding >> 2, 0, padding >> 2); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setEllipsize(TextUtils.TruncateAt.MIDDLE); tabTitleView.setMaxEms(9); tabTitleView.setSingleLine(true); tabView.setOnClickListener(tabClickListener); tabTitleView.setTextColor(ExplorerActivity.TEXT_COLOR); mTabStripLinearLayout.addView(tabView); } mTabStripLinearLayout.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND); }