List of usage examples for android.widget ImageView setImageDrawable
public void setImageDrawable(@Nullable Drawable drawable)
From source file:com.facebook.keyframes.sample.MainActivity.java
private void setKFImage(KFImage kfImage) { clearImage();//from w w w. j av a 2 s. c om mKfImage = kfImage; final Drawable logoDrawable = getResources().getDrawable(R.drawable.keyframes_launcher); if (logoDrawable != null) { logoDrawable.setBounds(0, 0, 80, 80); mKeyFramesDrawable = new KeyframesDrawableBuilder().withImage(mKfImage).withMaxFrameRate(60) .withExperimentalFeatures() .withParticleFeatureConfigs(Pair.create("keyframes", Pair.create(logoDrawable, new Matrix()))) .build(); } mKeyFramesDrawable.startAnimation(); final ImageView imageView = (ImageView) findViewById(R.id.sample_image_view); imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); imageView.setImageDrawable(mKeyFramesDrawable); }
From source file:am.project.x.business.drawables.loadingdrawable.LoadingDrawableActivity.java
private void setMaterialProgressDrawable() { final ImageView loading = findViewById(R.id.ld_iv_03); final MaterialProgressDrawable drawable = new MaterialProgressDrawable(density, MaterialProgressDrawable.DEFAULT, 0x00000000, 255, 0xff33b5e5, 0xff99cc00, 0xffff4444, 0xffffbb33); loading.setImageDrawable(drawable); drawable.start();//from w w w . j a va 2 s . co m }
From source file:edu.berkeley.boinc.adapter.NoticesListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Notice listItem = entries.get(position); LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.notices_layout_listitem, null); ImageView ivIcon = (ImageView) v.findViewById(R.id.projectIcon); Bitmap icon = getIcon(position);// w w w.j a va 2 s . co m // if available set icon, if not boinc logo if (icon == null) { ivIcon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.boinc)); } else { ivIcon.setImageBitmap(icon); } TextView tvProjectName = (TextView) v.findViewById(R.id.projectName); tvProjectName.setText(listItem.project_name); TextView tvNoticeTitle = (TextView) v.findViewById(R.id.noticeTitle); tvNoticeTitle.setText(listItem.title); TextView tvNoticeContent = (TextView) v.findViewById(R.id.noticeContent); tvNoticeContent.setText(Html.fromHtml(listItem.description)); TextView tvNoticeTime = (TextView) v.findViewById(R.id.noticeTime); tvNoticeTime.setText(DateUtils.formatDate(new java.util.Date((long) listItem.create_time * 1000))); v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "noticeClick: " + listItem.link); if (listItem.link != null && !listItem.link.isEmpty()) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(listItem.link)); activity.startActivity(i); } } }); return v; }
From source file:com.fast.access.kam.widget.colorpicker.dashclockpicker.ColorPickerDialogDash.java
private static void setColorViewValue(View view, int color) { if (view instanceof ImageView) { ImageView imageView = (ImageView) view; Resources res = imageView.getContext().getResources(); Drawable currentDrawable = imageView.getDrawable(); GradientDrawable colorChoiceDrawable; if (currentDrawable != null && currentDrawable instanceof GradientDrawable) { // Reuse drawable colorChoiceDrawable = (GradientDrawable) currentDrawable; } else {// w w w .java 2 s . c o m colorChoiceDrawable = new GradientDrawable(); colorChoiceDrawable.setShape(GradientDrawable.OVAL); } // Set stroke to dark version of color int darkenedColor = Color.rgb(Color.red(color) * 192 / 256, Color.green(color) * 192 / 256, Color.blue(color) * 192 / 256); colorChoiceDrawable.setColor(color); colorChoiceDrawable.setStroke( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics()), darkenedColor); imageView.setImageDrawable(colorChoiceDrawable); } else if (view instanceof TextView) { ((TextView) view).setTextColor(color); } }
From source file:com.esri.arcgisruntime.sample.editfeatureattachments.MainActivity.java
/** * Create a Layout for callout//from w ww . java 2 s . c o m */ private void createCallout() { // create content text view for the callout mCalloutLayout = new RelativeLayout(getApplicationContext()); TextView calloutContent = new TextView(getApplicationContext()); calloutContent.setId(R.id.calloutTextView); calloutContent.setTextColor(Color.BLACK); calloutContent.setTextSize(18); RelativeLayout.LayoutParams relativeParamsBelow = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParamsBelow.addRule(RelativeLayout.BELOW, calloutContent.getId()); // create attachment text view for the callout TextView calloutAttachment = new TextView(getApplicationContext()); calloutAttachment.setId(R.id.attchTV); calloutAttachment.setTextColor(Color.BLACK); calloutAttachment.setTextSize(13); calloutContent.setPadding(0, 20, 20, 0); calloutAttachment.setLayoutParams(relativeParamsBelow); RelativeLayout.LayoutParams relativeParamsRightOf = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParamsRightOf.addRule(RelativeLayout.RIGHT_OF, calloutAttachment.getId()); // create image view for the callout ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info)); imageView.setLayoutParams(relativeParamsRightOf); imageView.setOnClickListener(new ImageViewOnclickListener()); mCalloutLayout.addView(calloutContent); mCalloutLayout.addView(imageView); mCalloutLayout.addView(calloutAttachment); }
From source file:com.google.android.demos.jamendo.widget.SearchAdapter.java
private void bindImageView(View view, Cursor cursor, int viewId, String columnName) { ImageView imageView = (ImageView) view.findViewById(viewId); int columnIndex = cursor.getColumnIndexOrThrow(columnName); String url = cursor.getString(columnIndex); switch (mImageLoader.bind(this, imageView, url)) { case LOADING: case ERROR:/*w w w. j a va 2 s. c om*/ imageView.setImageDrawable(null); } }
From source file:am.project.x.business.drawables.loadingdrawable.LoadingDrawableActivity.java
private void setCirclingDrawable() { final ImageView loading = findViewById(R.id.ld_iv_02); final CirclingDrawable drawable = new CirclingDrawable((int) (4 * density), ContextCompat.getColor(this, R.color.colorAccent), ContextCompat.getDrawable(this, R.drawable.ic_drawables_drawable)); loading.setImageDrawable(drawable); drawable.start();/* ww w . j a v a 2s.c o m*/ }
From source file:cat.ereza.customactivityoncrash.activity.DefaultErrorReportActivity.java
@SuppressLint("PrivateResource") @Override// w w w .j a va2 s . co m protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); //This is needed to avoid a crash if the developer has not specified //an app-level theme that extends Theme.AppCompat TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme); if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) { setTheme(R.style.Theme_AppCompat_Light_DarkActionBar); } a.recycle(); setContentView(R.layout.customactivityoncrash_default_error_activity); //Close/restart button logic: //If a class if set, use restart. //Else, use close and just finish the app. //It is recommended that you follow this logic if implementing a custom error activity. Button restartButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_restart_button); final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent()); if (config.isShowRestartButton() && config.getRestartActivityClass() != null) { restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app); restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.restartApplication(DefaultErrorReportActivity.this, config); } }); } else { restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.closeApplication(DefaultErrorReportActivity.this, config); } }); } Button moreInfoButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_more_info_button); if (config.isShowErrorDetails()) { moreInfoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //We retrieve all the error data and show it AlertDialog dialog = new AlertDialog.Builder(DefaultErrorReportActivity.this) .setTitle(R.string.customactivityoncrash_error_activity_error_details_title) .setMessage(CustomActivityOnCrash .getAllErrorDetailsFromIntent(DefaultErrorReportActivity.this, getIntent())) .setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null) .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { copyErrorToClipboard(); Toast.makeText(DefaultErrorReportActivity.this, R.string.customactivityoncrash_error_activity_error_details_copied, Toast.LENGTH_SHORT).show(); } }) .show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size)); } }); } else { moreInfoButton.setVisibility(View.GONE); } Integer defaultErrorActivityDrawableId = config.getErrorDrawable(); ImageView errorImageView = ((ImageView) findViewById(R.id.customactivityoncrash_error_activity_image)); if (defaultErrorActivityDrawableId != null) { errorImageView.setImageDrawable( ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme())); } }
From source file:com.farmerbb.taskbar.adapter.StartMenuAdapter.java
@Override public @NonNull View getView(int position, View convertView, final @NonNull ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(isGrid ? R.layout.row_alt : R.layout.row, parent, false);/*from w ww . j a va 2s . c om*/ final AppEntry entry = getItem(position); assert entry != null; final SharedPreferences pref = U.getSharedPreferences(getContext()); TextView textView = (TextView) convertView.findViewById(R.id.name); textView.setText(entry.getLabel()); Intent intent = new Intent(); intent.setComponent(ComponentName.unflattenFromString(entry.getComponentName())); ActivityInfo activityInfo = intent.resolveActivityInfo(getContext().getPackageManager(), 0); if (activityInfo != null) textView.setTypeface(null, isTopApp(activityInfo) ? Typeface.BOLD : Typeface.NORMAL); switch (pref.getString("theme", "light")) { case "light": textView.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color)); break; case "dark": textView.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_dark)); break; } ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); imageView.setImageDrawable(entry.getIcon(getContext())); LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.entry); layout.setOnClickListener(view -> { LocalBroadcastManager.getInstance(getContext()) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); U.launchApp(getContext(), entry.getPackageName(), entry.getComponentName(), entry.getUserId(getContext()), null, false, false); }); layout.setOnLongClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); return true; }); layout.setOnGenericMotionListener((view, motionEvent) -> { int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); } if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true)) view.setBackgroundColor(0); return false; }); if (pref.getBoolean("visual_feedback", true)) { layout.setOnHoverListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) { int backgroundTint = pref.getBoolean("transparent_start_menu", false) ? U.getAccentColor(getContext()) : U.getBackgroundTint(getContext()); //noinspection ResourceAsColor backgroundTint = ColorUtils.setAlphaComponent(backgroundTint, Color.alpha(backgroundTint) / 2); v.setBackgroundColor(backgroundTint); } if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) v.setBackgroundColor(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) v.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT)); return false; }); layout.setOnTouchListener((v, event) -> { v.setAlpha( event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE ? 0.5f : 1); return false; }); } return convertView; }
From source file:com.azcltd.android.test.kolesov.DrawableManager.java
private void SetDrawableToImageView(Drawable image, ImageView imageView, boolean isNeedThumbnailed) { if (isNeedThumbnailed && (image != null)) { image = getThumbnail(image);/*w w w . j av a 2s . c o m*/ } if (image != null) { imageView.setImageDrawable(image); } }