List of usage examples for android.widget TextView setEllipsize
public void setEllipsize(TextUtils.TruncateAt where)
From source file:org.openremote.android.console.util.AsyncResourceLoader.java
/** * Update progress message in text./*ww w. jav a 2s. co m*/ * * @see android.os.AsyncTask#onProgressUpdate(Progress[]) */ @Override protected void onProgressUpdate(String... values) { RelativeLayout loadingView = (RelativeLayout) (activity.findViewById(R.id.welcome_view)); if (loadingView == null) { return; } TextView loadingText = (TextView) (activity.findViewById(R.id.loading_text)); loadingText.setText("loading " + values[0] + "..."); loadingText.setEllipsize(TruncateAt.MIDDLE); loadingText.setSingleLine(true); }
From source file:com.kaszubski.kamil.emmhelper.MainActivity.java
private void longTextTitleMode(boolean enabled) { try {// www . j av a 2 s . c o m Field titleField = Toolbar.class.getDeclaredField("mTitleTextView"); titleField.setAccessible(enabled); TextView barTitleView = (TextView) titleField.get(toolbar); barTitleView.setEllipsize(enabled ? TextUtils.TruncateAt.START : TextUtils.TruncateAt.START); barTitleView.setFocusable(enabled); barTitleView.setFocusableInTouchMode(enabled); barTitleView.requestFocus(); barTitleView.setSingleLine(enabled); barTitleView.setSelected(enabled); } catch (NoSuchFieldException e) { Log.e(TAG, "" + e); } catch (IllegalAccessException e) { Log.e(TAG, " " + e); } }
From source file:angeloid.dreamnarae.SwipeyTabs.java
/** * Update the ellipsize of the text views *///from ww w . j av a 2 s. com private void updateEllipsize() { if (mAdapter == null) { return; } final int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { TextView tab = (TextView) getChildAt(i); if (i < mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); } else if (i == mCurrentPos) { tab.setEllipsize(TruncateAt.END); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } else if (i > mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } } }
From source file:com.chess.genesis.view.SwipeTabs.java
/** * Update the ellipsize of the text views *///from ww w.jav a2 s .co m private void updateEllipsize() { if (mAdapter == null) return; final int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { final TextView tab = (TextView) getChildAt(i); if (i < mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } else if (i == mCurrentPos) { tab.setEllipsize(TruncateAt.END); tab.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL); } else if (i > mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); } } }
From source file:org.mozilla.gecko.overlays.ui.ShareDialog.java
@Override protected void onResume() { super.onResume(); final Intent intent = getIntent(); state = intent.getBooleanExtra(INTENT_EXTRA_DEVICES_ONLY, false) ? State.DEVICES_ONLY : State.DEFAULT; // If the Activity is being reused, we need to reset the state. Ideally, we create a // new instance for each call, but Android L breaks this (bug 1137928). sendTabList.switchState(SendTabList.State.LOADING); readingListButton.setBackgroundDrawable(readingListButtonDrawable); // The URL is usually hiding somewhere in the extra text. Extract it. final String extraText = ContextUtils.getStringExtra(intent, Intent.EXTRA_TEXT); if (TextUtils.isEmpty(extraText)) { abortDueToNoURL();//from w w w . ja v a2s.c o m return; } final String pageUrl = new WebURLFinder(extraText).bestWebURL(); if (TextUtils.isEmpty(pageUrl)) { abortDueToNoURL(); return; } // Have the service start any initialisation work that's necessary for us to show the correct // UI. The results of such work will come in via the BroadcastListener. Intent serviceStartupIntent = new Intent(this, OverlayActionService.class); serviceStartupIntent.setAction(OverlayConstants.ACTION_PREPARE_SHARE); startService(serviceStartupIntent); // Start the slide-up animation. getWindow().setWindowAnimations(0); final Animation anim = AnimationUtils.loadAnimation(this, R.anim.overlay_slide_up); findViewById(R.id.sharedialog).startAnimation(anim); // If provided, we use the subject text to give us something nice to display. // If not, we wing it with the URL. // TODO: Consider polling Fennec databases to find better information to display. final String subjectText = intent.getStringExtra(Intent.EXTRA_SUBJECT); final String telemetryExtras = "title=" + (subjectText != null); if (subjectText != null) { ((TextView) findViewById(R.id.title)).setText(subjectText); } Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.SHARE_OVERLAY, telemetryExtras); title = subjectText; url = pageUrl; // Set the subtitle text on the view and cause it to marquee if it's too long (which it will // be, since it's a URL). final TextView subtitleView = (TextView) findViewById(R.id.subtitle); subtitleView.setText(pageUrl); subtitleView.setEllipsize(TextUtils.TruncateAt.MARQUEE); subtitleView.setSingleLine(true); subtitleView.setMarqueeRepeatLimit(5); subtitleView.setSelected(true); final View titleView = findViewById(R.id.title); if (state == State.DEVICES_ONLY) { bookmarkButton.setVisibility(View.GONE); readingListButton.setVisibility(View.GONE); titleView.setOnClickListener(null); subtitleView.setOnClickListener(null); return; } bookmarkButton.setVisibility(View.VISIBLE); readingListButton.setVisibility(View.VISIBLE); // Configure buttons. final View.OnClickListener launchBrowser = new View.OnClickListener() { @Override public void onClick(View view) { ShareDialog.this.launchBrowser(); } }; titleView.setOnClickListener(launchBrowser); subtitleView.setOnClickListener(launchBrowser); final LocalBrowserDB browserDB = new LocalBrowserDB(getCurrentProfile()); setButtonState(url, browserDB); }
From source file:com.orange.ocara.ui.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);// w w w .j a v a 2 s . c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setBackgroundResource(tabBackgroundResId); tab.setTextColor(tabTextColor); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setEllipsize(TextUtils.TruncateAt.MARQUEE); tab.setAllCaps(true); addTab(position, tab); }
From source file:fr.cph.chicago.core.activity.StationActivity.java
/** * Draw line//from w w w . j av a2s .c om * * @param eta the eta */ public void drawAllArrivalsTrain(@NonNull final Eta eta) { final TrainLine line = eta.getRouteName(); final Stop stop = eta.getStop(); final String key = line.toString() + "_" + stop.getDirection().toString(); // viewId might be not there if CTA API provide wrong data if (ids.containsKey(key)) { final int viewId = ids.get(key); final LinearLayout line3View = (LinearLayout) findViewById(viewId); final Integer id = ids .get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName()); if (id == null) { final LinearLayout insideLayout = new LinearLayout(this); insideLayout.setOrientation(LinearLayout.HORIZONTAL); insideLayout.setLayoutParams(paramsStop); final int newId = Util.generateViewId(); insideLayout.setId(newId); ids.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId); final TextView stopName = new TextView(this); final String stopNameData = eta.getDestName() + ": "; stopName.setText(stopNameData); stopName.setTextColor(grey); stopName.setPadding(line3PaddingLeft, line3PaddingTop, 0, 0); insideLayout.addView(stopName); final TextView timing = new TextView(this); final String timingData = eta.getTimeLeftDueDelay() + " "; timing.setText(timingData); timing.setTextColor(grey); timing.setLines(1); timing.setEllipsize(TruncateAt.END); insideLayout.addView(timing); line3View.addView(insideLayout); } else { final LinearLayout insideLayout = (LinearLayout) findViewById(id); final TextView timing = (TextView) insideLayout.getChildAt(1); final String timingData = timing.getText() + eta.getTimeLeftDueDelay() + " "; timing.setText(timingData); } line3View.setVisibility(View.VISIBLE); } }
From source file:org.nativescript.widgets.TabLayout.java
/** * Create a default view to be used for tabs. *///w w w .j a v a 2 s. c om protected View createDefaultTabView(Context context, TabItemSpec tabItem) { float density = getResources().getDisplayMetrics().density; int padding = (int) (TAB_VIEW_PADDING_DIPS * density); LinearLayout ll = new LinearLayout(context); ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setGravity(Gravity.CENTER); ll.setOrientation(LinearLayout.VERTICAL); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); ll.setBackgroundResource(outValue.resourceId); ImageView imgView = new ImageView(context); imgView.setScaleType(ScaleType.FIT_CENTER); LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); imgLP.gravity = Gravity.CENTER; imgView.setLayoutParams(imgLP); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setMaxWidth((int) (TEXT_MAX_WIDTH * density)); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setAllCaps(true); textView.setMaxLines(2); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, 0, padding, 0); this.setupItem(ll, textView, imgView, tabItem); ll.addView(imgView); ll.addView(textView); return ll; }
From source file:so.contacts.hub.basefunction.widget.viewpagerindicator.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w . ja v a 2 s. co m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setEllipsize(TruncateAt.END); addTab(position, tab); }
From source file:com.arcgis.android.samples.localdata.localrasterdata.FileBrowserFragment.java
private void createFileListAdapter() { adapter = new ArrayAdapter<Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, fileList) {//from ww w. ja v a 2s. co m @Override public View getView(int position, View convertView, ViewGroup parent) { // creates view View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); // put the image on the text view int drawableID = 0; if (fileList.get(position).icon != -1) { // If icon == -1, then directory is empty drawableID = fileList.get(position).icon; } textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0, 0, 0); textView.setEllipsize(null); int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f); textView.setCompoundDrawablePadding(dp3); textView.setBackgroundColor(Color.LTGRAY); return view; } }; }