List of usage examples for android.widget TextView setCompoundDrawablesWithIntrinsicBounds
@android.view.RemotableViewMethod public void setCompoundDrawablesWithIntrinsicBounds(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom)
From source file:github.daneren2005.dsub.util.ImageLoader.java
private void setImage(View view, final Drawable drawable, boolean crossfade) { if (view instanceof TextView) { // Cross-fading is not implemented for TextView since it's not in use. It would be easy to add it, though. TextView textView = (TextView) view; textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); } else if (view instanceof ImageView) { final ImageView imageView = (ImageView) view; if (crossfade && drawable != null) { Drawable existingDrawable = imageView.getDrawable(); if (existingDrawable == null) { Bitmap emptyImage;/* www .ja v a 2s .co m*/ if (drawable.getIntrinsicWidth() > 0 && drawable.getIntrinsicHeight() > 0) { emptyImage = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); } else { emptyImage = Bitmap.createBitmap(imageSizeDefault, imageSizeDefault, Bitmap.Config.ARGB_8888); } existingDrawable = new BitmapDrawable(context.getResources(), emptyImage); } else if (existingDrawable instanceof TransitionDrawable) { // This should only ever be used if user is skipping through many songs quickly TransitionDrawable tmp = (TransitionDrawable) existingDrawable; existingDrawable = tmp.getDrawable(tmp.getNumberOfLayers() - 1); } if (existingDrawable != null && drawable != null) { Drawable[] layers = new Drawable[] { existingDrawable, drawable }; final TransitionDrawable transitionDrawable = new TransitionDrawable(layers); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(250); // Get rid of transition drawable after transition occurs handler.postDelayed(new Runnable() { @Override public void run() { // Only execute if still on same transition drawable if (imageView.getDrawable() == transitionDrawable) { imageView.setImageDrawable(drawable); } } }, 500L); } else { imageView.setImageDrawable(drawable); } } else { imageView.setImageDrawable(drawable); } } }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
@Override public void onCreate(Bundle savedInstanceState) { ThemeUtils.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.about);/*w w w. j a va 2 s. com*/ ThemeUtils.fixSmartBar(this); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { getActionBar().setDisplayHomeAsUpEnabled(true); } WebView webView = (WebView) findViewById(R.id.webview); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); if ("zh".equals(Locale.getDefault().getLanguage())) { webView.loadUrl("file:///android_asset/about.zh.html"); } else { webView.loadUrl("file:///android_asset/about.en.html"); } setView(R.id.alipay, "com.eg.android.AlipayGphone"); if (hasPermission()) { setView(R.id.wechat, "com.tencent.mm"); } else { findViewById(R.id.wechat).setVisibility(View.GONE); } if (!setView(R.id.paypal, "com.paypal.android.p2pmobile")) { TextView paypal = (TextView) findViewById(R.id.paypal); paypal.setClickable(true); paypal.setOnClickListener(this); paypal.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(paypal.getCompoundDrawables()[1]), null, null); } if (setView(R.id.play, "com.android.vending")) { findViewById(R.id.play).setVisibility(View.GONE); checkDonate(); } donateView = findViewById(R.id.donate); if (BuildConfig.DONATE && TextUtils.isEmpty(LicenseUtils.getLicense(this))) { donateView.setVisibility(View.VISIBLE); } else { donateView.setVisibility(View.GONE); } retrieveInfo(); }
From source file:com.sentaroh.android.TextFileBrowser.ViewedFileListAdapter.java
@SuppressWarnings("deprecation") @Override//from w w w .j a v a 2s. c o m public View getView(int position, View convertView, ViewGroup parent) { TextView view; if (convertView == null) { LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = (TextView) vi.inflate(mResourceId, null); } else { view = (TextView) convertView; } // view=(TextView)super.getView(position,convertView,parent); view.setText(getItem(position).file_name); view.setCompoundDrawablePadding(10); view.setCompoundDrawablesWithIntrinsicBounds( mContext.getResources().getDrawable(android.R.drawable.arrow_down_float), null, null, null); // view.setTextColor(Color.BLACK); // if (text_size!=0) view.setTextSize(text_size); return view; }
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 . j av a2 s . c o 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; } }; }
From source file:net.sf.diningout.app.ui.FriendsFragment.java
/** * Update the action View text and icon based on its state. *//*www. ja va 2s .co m*/ private void updateAction(TextView view, boolean isChecked, boolean isUser) { if (isChecked) { view.setText(isUser ? R.string.following : R.string.inviting); view.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_accept_small, 0, 0, 0); } else { view.setText(isUser ? R.string.follow : R.string.invite); view.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_new_small, 0, 0, 0); } }
From source file:com.sentaroh.android.TextFileBrowser.ViewedFileListAdapter.java
@SuppressWarnings("deprecation") @Override/*from ww w . ja v a 2 s . co m*/ public View getDropDownView(int position, View convertView, ViewGroup parent) { final TextView text = (TextView) super.getDropDownView(position, convertView, parent); // text.setBackgroundColor(Color.LTGRAY); if (Build.VERSION.SDK_INT >= 11) { // text.setCompoundDrawablePadding(10); // text.setCompoundDrawablesWithIntrinsicBounds( // mContext.getResources().getDrawable(android.R.drawable.btn_radio), // null, null, null); text.setCompoundDrawablesWithIntrinsicBounds(null, null, mContext.getResources().getDrawable(android.R.drawable.btn_radio), null); } text.setText(getItem(position).file_path); // text.setEllipsize(TruncateAt.START); text.post(new Runnable() { @Override public void run() { text.setSingleLine(false); } }); // text.setTextColor(Color.BLACK); // if (text_color!=0) text.setTextColor(text_color); // if (text_size!=0) text.setTextSize(text_size); return text; }
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 va 2 s . c om*/ 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:net.naonedbus.fragment.CustomListFragment.java
/** * Afficher un message avec une desciption et un symbole. * //from w w w . j a va2 s .com * @param title * Le titre. * @param description * La description. * @param drawableRes * L'identifiant du symbole. */ protected void showMessage(final String title, final String description, final int drawableRes) { if (State.MESSAGE == mCurrentState) { return; } if (DBG) Log.d(LOG_TAG + "$" + getClass().getSimpleName(), "showMessage " + title + "\t" + description + "\t" + drawableRes); mCurrentState = State.MESSAGE; mFragmentView.findViewById(android.R.id.list).setVisibility(View.GONE); mFragmentView.findViewById(R.id.fragmentLoading).setVisibility(View.GONE); View message = mFragmentView.findViewById(R.id.fragmentMessage); if (message == null) { final ViewStub messageStrub = (ViewStub) mFragmentView.findViewById(R.id.fragmentMessageStub); message = messageStrub.inflate(); } message.setVisibility(View.VISIBLE); final TextView titleView = (TextView) message.findViewById(android.R.id.title); titleView.setText(title); titleView.setCompoundDrawablesWithIntrinsicBounds(0, drawableRes, 0, 0); final TextView descriptionView = (TextView) message.findViewById(android.R.id.summary); if (description != null) { descriptionView.setText(description); descriptionView.setVisibility(View.VISIBLE); } else { descriptionView.setVisibility(View.GONE); } }
From source file:org.telegram.ui.SettingsBlockedUsers.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;/* www. 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.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.achep.base.ui.DialogBuilder.java
private View createSkeleton() { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout rootLayout = (LinearLayout) inflater.inflate(R.layout.dialog_main_skeleton, new FrameLayout(mContext), false); TextView titleView = (TextView) rootLayout.findViewById(R.id.title); if (Device.hasLollipopApi()) { // The dividers are quite ugly with material design. rootLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); }// ww w .j a va 2 s . c o m if (mTitleText == null && mIcon == null) { rootLayout.removeView(titleView); } else { if (mTitleText != null) titleView.setText(mTitleText); if (mIcon != null) titleView.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null); } return rootLayout; }