List of usage examples for android.graphics.drawable Drawable setBounds
public void setBounds(int left, int top, int right, int bottom)
From source file:com.pengfei.fastopen.adapter.SettingAdapter.java
private void childUninstallApp(View convertView, final int groupPosition, final int childPosition, final SaveAppEntity child, TextView item) { item.setText(child.getName());/* www .j ava 2 s. c o m*/ byte[] icon = child.getIcon(); if (icon != null) { Bitmap bitmap = ImageUtils.changeByteToBitmap(icon); Drawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setBounds(0, 0, 36, 36); item.setCompoundDrawables(drawable, null, null, null); } final String[] items = new String[] { "", "" }; convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogUtils.getItemsDialog(child.getName(), context, items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: IntentUtils.openApplicationMarket(context, child.getPackageName()); break; case 1: SaveAppDBManager.deleteApp(child.getPackageName()); list.get(groupPosition).childItems.remove(childPosition); notifyDataSetChanged(); list.get(groupPosition).updateName(); Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); break; } } }).create().show(); } }); }
From source file:com.eutectoid.dosomething.usersettings.UserSettingsFragment.java
private void updateUI() { if (!isAdded()) { return;//from w ww. j a va 2 s. c o m } if (AccessToken.getCurrentAccessToken() != null) { connectedStateLabel .setTextColor(getResources().getColor(R.color.usersettings_fragment_connected_text_color)); connectedStateLabel.setShadowLayer(1f, 0f, -1f, getResources().getColor(R.color.usersettings_fragment_connected_shadow_color)); if (user != null) { ImageRequest request = getImageRequest(); if (request != null) { Uri requestUri = request.getImageUri(); // Do we already have the right picture? If so, leave it alone. if (!requestUri.equals(connectedStateLabel.getTag())) { if (user.optString("id").equals(userProfilePicID)) { connectedStateLabel.setCompoundDrawables(null, userProfilePic, null, null); connectedStateLabel.setTag(requestUri); } else { ImageDownloader.downloadAsync(request); } } } connectedStateLabel.setText(user.optString("name")); } else { connectedStateLabel.setText(getResources().getString(R.string.usersettings_fragment_logged_in)); Drawable noProfilePic = getResources().getDrawable(R.drawable.profile_default_icon); noProfilePic.setBounds(0, 0, getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.usersettings_fragment_profile_picture_height)); connectedStateLabel.setCompoundDrawables(null, noProfilePic, null, null); } } else { int textColor = getResources().getColor(R.color.usersettings_fragment_not_connected_text_color); connectedStateLabel.setTextColor(textColor); connectedStateLabel.setShadowLayer(0f, 0f, 0f, textColor); connectedStateLabel.setText(getResources().getString(R.string.usersettings_fragment_not_logged_in)); connectedStateLabel.setCompoundDrawables(null, null, null, null); connectedStateLabel.setTag(null); } }
From source file:com.silentcircle.contacts.calllognew.CallTypeIconsView.java
@Override protected void onDraw(Canvas canvas) { int left = 0; for (Integer callType : mCallTypes) { final Drawable drawable = getCallTypeDrawable(callType); final int right = left + drawable.getIntrinsicWidth(); drawable.setBounds(left, 0, right, drawable.getIntrinsicHeight()); drawable.draw(canvas);//w ww. ja v a 2 s .c om left = right + mResources.iconMargin; } // If showing the video call icon, draw it scaled appropriately. // if (mShowVideo) { // final Drawable drawable = mResources.videoCall; // final int right = left + mResources.videoCall.getIntrinsicWidth(); // drawable.setBounds(left, 0, right, mResources.videoCall.getIntrinsicHeight()); // drawable.draw(canvas); // } }
From source file:org.glucosio.android.activity.HelloActivity.java
private void initStartButton() { final Drawable pinkArrow = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_navigate_next_pink_24px, null); if (pinkArrow != null) { pinkArrow.setBounds(0, 0, 60, 60); startButton.setCompoundDrawables(null, null, pinkArrow, null); }/*from ww w. ja va 2 s.c o m*/ }
From source file:org.videolan.vlc.gui.SidebarAdapter.java
@Override public View getView(int position, View v, ViewGroup parent) { SidebarEntry sidebarEntry = entries.get(position); /* If view not created */ if (v == null) { v = mInflater.inflate(R.layout.sidebar_item, parent, false); }// w ww.j ava2 s . c om TextView textView = (TextView) v; textView.setText(sidebarEntry.name); Drawable img = VLCApplication.getAppResources().getDrawable(sidebarEntry.drawableID); if (img != null) { int dp_32 = Util.convertDpToPx(32); img.setBounds(0, 0, dp_32, dp_32); textView.setCompoundDrawables(img, null, null, null); } return v; }
From source file:com.freshdigitable.udonroad.MediaImageView.java
public MediaImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setContentDescription(getResources().getString(R.string.tweet_media_descs)); setVisibility(GONE);//from w w w. j av a 2 s.c o m if (playIcon == null) { final Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ld_play_icon); playIcon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(playIcon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } }
From source file:com.jun.elephant.ui.topic.details.TopicDetailsActivity.java
private void setDrawableTop(TextView textView, int resId) { Drawable drawable = ContextCompat.getDrawable(this, resId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); textView.setCompoundDrawables(null, drawable, null, null); }
From source file:com.jun.elephant.ui.topic.details.TopicDetailsActivity.java
private void setDrawableLeft(TextView textView, int resId) { Drawable drawable = ContextCompat.getDrawable(this, resId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); textView.setCompoundDrawables(drawable, null, null, null); }
From source file:fr.ippon.android.opendata.android.AbstractParkingListFragment.java
private void configureSearchField(RelativeLayout r) { final AbstractParkingListFragment loaderCallBack = this; searchField = (EditText) r.findViewById(R.id.searchField); if (TextUtils.isEmpty(searchField.getText())) searchField.setText(searchHint); searchField.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // hide the keyboard InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(searchField.getWindowToken(), 0); // Perform action on key press boolean okSearch = !TextUtils.isEmpty(searchField.getText()) && !searchHint.equals(searchField.getText()); queryText = okSearch ? searchField.getText().toString() : null; Log.d(TAG, "query: " + queryText); hasSearched = true;/*from w w w. j a v a2 s .co m*/ getLoaderManager().restartLoader(0, null, loaderCallBack); if (queryText == null) { searchField.setText(searchHint); } return true; } return false; } }); // afichage d'une croix dans l'edit text pour effacer le texte saisie final Drawable x = getResources().getDrawable(R.drawable.ic_cancel); x.setBounds(0, 0, x.getIntrinsicWidth(), x.getIntrinsicHeight()); searchField.setCompoundDrawables(null, null, x, null); searchField.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && searchHint.equals(searchField.getText().toString())) { searchField.setText(""); } if (searchField.getCompoundDrawables()[2] == null) { // cross is not being shown so no need to handle return false; } if (event.getAction() != MotionEvent.ACTION_DOWN) { // only respond to the down type return false; } if (event.getX() > searchField.getMeasuredWidth() - searchField.getPaddingRight() - x.getIntrinsicWidth()) { searchField.setText(""); return true; } else { return false; } } }); }
From source file:com.jaspersoft.android.jaspermobile.util.resource.viewbinder.CustomBitmapProcessor.java
public Bitmap convertToBitmap(Drawable drawable) { int widthPixels = drawable.getIntrinsicWidth(); int heightPixels = drawable.getIntrinsicHeight(); Bitmap mutableBitmap = Bitmap.createBitmap(widthPixels, heightPixels, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mutableBitmap); drawable.setBounds(0, 0, widthPixels, heightPixels); drawable.draw(canvas);//from w ww .j a v a 2 s . c o m return mutableBitmap; }