Tag Archives: imageview
3,527 views
Create Image From View Screen Android
WebView_webview = (WebView)findViewById(R.id.webViewMapa); _webview.getSettings().setBuiltInZoomControls(true); _webview.setBackgroundColor(Color.parseColor("#E8EAE8")); // _webview.loadUrl( … some your page Bitmap b = Bitmap.createBitmap(_webview.getWidth()/2, _webview.getHeight(), Bitmap.Config.ARGB_8888); // you can to draw on bitmap Canvas c = new Canvas(b); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(15.f); paint.setColor(Color.RED); paint.setStyle(Paint.Style.STROKE); //paint.setShadowLayer(5.f, 0, … Continue reading
Resize ImageView Image in View Android Example
How to resize an image in ImageView Android source code. Resize imageview layout and image will resize too: public void resizeImageView(int width, int height) { final ImageView picture1 = (ImageView)findViewById(R.id.imageView1); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height); picture1.setLayoutParams(layoutParams); }
Error android.widget.LinearLayout.measureHorizontal LinearLayout.java
Code with error: ImageView imgV = (ImageView)findViewById(R.id.myView); imgV.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, 0)); If you get error try this code: ViewGroup.LayoutParams layoutParams = imgV .getLayoutParams(); layoutParams.height = 0; imgV.setLayoutParams(layoutParams); java.lang.ClassCastException: android.view.ViewGroup$LayoutParams at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:659) at android.widget.LinearLayout.onMeasure(LinearLayout.java:311) at android.view.View.measure(View.java:8313) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017) at … Continue reading
How to clear or hide an ImageView in Android
// solution 1 ImageView imageView = (ImageView)findViewById(R.id.myimage); imageView.setImageDrawable(null); // or imageView.setImageResource(0); // solution 2 hide ImageView imageView.setVisibility(View.INVISIBLE); // solution 3 resize ImageView 0, 0 hImageViewSemafor.setLayoutParams(new LinearLayout.LayoutParams(0,0));
ImageView change image Android example
How to change the image dynamically in ImageView and button setOnClickListener Android sample. Main.java ipackage cz.okhelp.my_game; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; public class Main extends Activity { private ImageView … Continue reading
ImageView Android example
ImageView basic Android sample. ImagView using image formats like this PNG, JPG, GIF and etc. Images is stored in res/drawable folder. Application’s icons in: drawable-hdpi drawable-ldpi drawable-mdpi main.xml Put into res/drawable this image: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" … Continue reading
Download file from URL
Download image file from URL to ImageView Java Android source example code. Context context = thisClass.this; Drawable image = ImageOperations(context, "http://android.okhelp.cz/images/adictionary/ad_4.png" ,"image.jpg"); ImageView imgView; imgView = (ImageView)findViewById(R.id.idImageView); imgView.setImageDrawable(image); private Drawable ImageOperations(Context ctx, String url, String saveFilename) { try { … Continue reading