List of usage examples for android.widget TextView setCompoundDrawablePadding
@android.view.RemotableViewMethod public void setCompoundDrawablePadding(int pad)
From source file:org.telegram.ui.LocationActivity.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;// ww w . java 2 s.co m } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setSubtitle(null); actionBar.setDisplayShowCustomEnabled(false); actionBar.setCustomView(null); if (messageObject != null) { actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); } else { actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation)); } TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } }
From source file:in.shick.diode.common.Common.java
/** * Helper function to display a list of URLs. * @param theContext The current application context. * @param settings The settings to use regarding the browser component. * @param theItem The ThingInfo item to get URLs from. */// w ww.j a v a 2 s . c om public static void showLinksDialog(final Context theContext, final RedditSettings settings, final ThingInfo theItem) { assert (theContext != null); assert (theItem != null); assert (settings != null); final ArrayList<String> urls = new ArrayList<String>(); final ArrayList<MarkdownURL> vtUrls = theItem.getUrls(); for (MarkdownURL vtUrl : vtUrls) { urls.add(vtUrl.url); } ArrayAdapter<MarkdownURL> adapter = new ArrayAdapter<MarkdownURL>(theContext, android.R.layout.select_dialog_item, vtUrls) { public View getView(int position, View convertView, ViewGroup parent) { TextView tv; if (convertView == null) { tv = (TextView) ((LayoutInflater) theContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(android.R.layout.select_dialog_item, null); } else { tv = (TextView) convertView; } String url = getItem(position).url; String anchorText = getItem(position).anchorText; // if (Constants.LOGGING) Log.d(TAG, "links url="+url + " anchorText="+anchorText); Drawable d = null; try { d = theContext.getPackageManager() .getActivityIcon(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } catch (PackageManager.NameNotFoundException ignore) { } if (d != null) { d.setBounds(0, 0, d.getIntrinsicHeight(), d.getIntrinsicHeight()); tv.setCompoundDrawablePadding(10); tv.setCompoundDrawables(d, null, null, null); } final String telPrefix = "tel:"; if (url.startsWith(telPrefix)) { url = PhoneNumberUtils.formatNumber(url.substring(telPrefix.length())); } if (anchorText != null) tv.setText(Html.fromHtml("<span>" + anchorText + "</span><br /><small>" + url + "</small>")); else tv.setText(Html.fromHtml(url)); return tv; } }; AlertDialog.Builder b = new AlertDialog.Builder( new ContextThemeWrapper(theContext, settings.getDialogTheme())); DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() { public final void onClick(DialogInterface dialog, int which) { if (which >= 0) { Common.launchBrowser(settings, theContext, urls.get(which), Util.createThreadUri(theItem).toString(), false, false, settings.isUseExternalBrowser(), settings.isSaveHistory()); } } }; b.setTitle(R.string.select_link_title); b.setCancelable(true); b.setAdapter(adapter, click); b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public final void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); b.show(); }
From source file:com.astuetz.PagerSlidingTabStripMenu.java
private void addIconTab2(final int position, String title, int resId) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w. jav a2s . co m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setCompoundDrawablePadding(mTabDrawablePadding); switch (mIconPostion) { case Left: tab.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0); break; case Top: tab.setCompoundDrawablesWithIntrinsicBounds(0, resId, 0, 0); break; case Right: tab.setCompoundDrawablesWithIntrinsicBounds(0, 0, resId, 0); break; case Bottom: tab.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, resId); break; } addTab(position, tab); }
From source file:org.telegram.ui.SettingsBlockedUsers.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;/*from www. java 2 s .c o m*/ } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setSubtitle(null); actionBar.setCustomView(null); actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } ((LaunchActivity) parentActivity).fixBackButton(); }
From source file:com.bwash.bwashcar.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title, int res) { View view = View.inflate(getContext(), R.layout.tab_item_layout, null); TextView tab = (TextView) view.findViewById(R.id.text); tab.setText(title);// w w w. j a v a 2 s . co m tab.setSingleLine(); tab.setBackgroundResource(R.color.white); tab.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(res), null, null, null); tab.setCompoundDrawablePadding(ViewUtils.dip2px(getContext(), 5)); addTab(position, view); }
From source file:com.nadmm.airports.wx.MetarFragment.java
protected void showWindInfo(LinearLayout layout, Metar metar) { View row = addRow(layout, getWindsDescription(metar)); TextView tv = (TextView) row.findViewById(R.id.item_label); if (metar.windDirDegrees > 0) { float declination = GeoUtils.getMagneticDeclination(mLocation); Drawable wind = WxUtils.getWindBarbDrawable(tv.getContext(), metar, declination); tv.setCompoundDrawablesWithIntrinsicBounds(wind, null, null, null); tv.setCompoundDrawablePadding(UiUtils.convertDpToPx(getActivity(), 6)); }//from w w w . ja v a 2s. c o m if (metar.windGustKnots < Integer.MAX_VALUE) { double gustFactor = metar.windGustKnots - metar.windSpeedKnots; addRow(layout, String.format("Add %d knots to your normal approach speed", Math.round(gustFactor / 2))); } if (metar.wshft) { StringBuilder sb = new StringBuilder(); sb.append("Wind shift of 45\u00B0 or more detected during past hour"); if (metar.fropa) { sb.append(" due to frontal passage"); } addRow(layout, sb.toString()); } }
From source file:com.yahala.ui.GroupCreateFinalActivity.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;/*from w ww. j av a 2 s .c o m*/ } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setCustomView(null); actionBar.setSubtitle(null); actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } }
From source file:com.ds.avare.utils.FolderPreference.java
/** * //from w ww . j ava 2 s. c o m */ private void loadFileList() { /* * Checks whether mPath exists */ if (mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String filename) { File sel = new File(dir, filename); /* * Filters based on whether the file is hidden or not, and is a folder */ return (!sel.isHidden()); } }; String[] fList = mPath.list(filter); if (fList == null) { fList = new String[0]; } mFileList = new Item[fList.length]; for (int i = 0; i < fList.length; i++) { mFileList[i] = new Item(fList[i], android.R.drawable.alert_light_frame); /* * Convert into file mPath */ File sel = new File(mPath, fList[i]); /* * Set drawables */ if (sel.isDirectory()) { if (sel.canWrite()) { mFileList[i].icon = android.R.drawable.ic_menu_save; } else { mFileList[i].icon = android.R.drawable.ic_lock_lock; } } /* * File is for information only */ else { mFileList[i].icon = android.R.drawable.alert_light_frame; } } if (!mFirstLevel) { Item temp[] = new Item[mFileList.length + 1]; for (int i = 0; i < mFileList.length; i++) { temp[i + 1] = mFileList[i]; } temp[0] = new Item(mContext.getString(R.string.Up), android.R.drawable.ic_menu_revert); mFileList = temp; } } if (mFileList == null) { return; } /* * Set the adapter with file list */ mAdapter = new ArrayAdapter<Item>(mContext, android.R.layout.select_dialog_item, android.R.id.text1, mFileList) { @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 */ textView.setCompoundDrawablesWithIntrinsicBounds(mFileList[position].icon, 0, 0, 0); /* * add margin between image and text (support various screen */ textView.setCompoundDrawablePadding(10); textView.setTextColor(Color.parseColor("#FF71BC78")); return view; } }; /* * Show where we are */ mPathView.setText(mPath.getAbsolutePath()); }
From source file:com.yahala.ui.LanguageSelectActivity.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;//from ww w. j a v a 2 s .c o m } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setCustomView(null); actionBar.setSubtitle(null); TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } actionBar.setTitle(LocaleController.getString("Language", R.string.Language)); ((LaunchActivity) parentActivity).fixBackButton(); }
From source file:net.etuldan.sparss.fragment.EntriesListFragment.java
@Override public View inflateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_entry_list, container, true); if (mEntriesCursorAdapter != null) { setListAdapter(mEntriesCursorAdapter); }// ww w. j a va2s.c o m mListView = (ListView) rootView.findViewById(android.R.id.list); mListView.setOnTouchListener(new SwipeGestureListener(mListView.getContext())); if (PrefUtils.getBoolean(PrefUtils.DISPLAY_TIP, true)) { final TextView header = new TextView(mListView.getContext()); header.setMinimumHeight(UiUtils.dpToPixel(70)); int footerPadding = UiUtils.dpToPixel(10); header.setPadding(footerPadding, footerPadding, footerPadding, footerPadding); header.setText(R.string.tip_sentence); header.setGravity(Gravity.CENTER_VERTICAL); header.setCompoundDrawablePadding(UiUtils.dpToPixel(5)); header.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_info_outline, 0, R.drawable.ic_cancel, 0); header.setClickable(true); header.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mListView.removeHeaderView(header); PrefUtils.putBoolean(PrefUtils.DISPLAY_TIP, false); } }); mListView.addHeaderView(header); } UiUtils.addEmptyFooterView(mListView, 90); mHideReadButton = (FloatingActionButton) rootView.findViewById(R.id.hide_read_button); mHideReadButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { UiUtils.displayHideReadButtonAction(mListView.getContext()); return true; } }); UiUtils.updateHideReadButton(mHideReadButton); mSearchView = (SearchView) rootView.findViewById(R.id.searchView); if (savedInstanceState != null) { refreshUI(); // To hide/show the search bar } mSearchView.post(new Runnable() { // Do this AFTER the text has been restored from saveInstanceState @Override public void run() { mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0); return false; } @Override public boolean onQueryTextChange(String s) { setData(EntryColumns.SEARCH_URI(s), true); return false; } }); } }); disableSwipe(); return rootView; }