Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Rounded rect RectF Android example



RectF, drawRoundRect(),

public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
           Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
           Canvas c = new Canvas(b);
           RectF rectF = new RectF();
           rectF.set(5,5,150,150);
           c.drawRoundRect(rectF, 10, 10, paint);
           
            paint.setColor(Color.RED);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}


draw-rounded-rect-android

397LW NO topic_id



Další témata ....(Topics)


155

Hue saturation, color, colored filtering Bitmap Image Android example | hue-color-colored-filter-bitmap-image-android-example


colored filtering bitmap android

/* Copyright (C) 2011 The Android Open Source Project
//www.apache.org/licenses/LICENSE-2.0
*/
public class MainActivity extends Activity {
private ImageView imageView;
private Button button1;
Drawable bitmapOrg;
private final int[] mColors =
{Color.BLUE, Color.GREEN, Color.RED, Color.LTGRAY, Color.MAGENTA, Color.CYAN,
		Color.YELLOW, Color.WHITE};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		imageView = (ImageView)findViewById(R.id.imageView1);
		button1 = (Button)findViewById(R.id.button1);

		
		bitmapOrg = this.getResources().getDrawable(R.drawable.flower_blue);
        
        button1.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                int mColor = (int) Math.floor(Math.random() * mColors.length);
                bitmapOrg.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);
                imageView.setImageDrawable(bitmapOrg);
                imageView.invalidate();
            }
        });	
 	}

}

199

Nejlepší mobil s Androidem - jak nakupovat | nejlepsi-mobil-s-androidem-jak-nakupovat


Kvalitní mobilní telefon pro rok 2012 by měl mít tyto, nebo ještě lepší parametry.
Značka Samsung , HTC, LG, Motorola, Sony Ericsson, ZTE Blade
Verze operačního systému Android 2.2 a vyšší.
Procesor a jeho frekvence Qualcomm 800MHz a vyšší.
Paměť RAM 512MB a více.
Paměť ROM 512MB.
Displej a jeho rozlišení 4,3 palce rozlišení 480x800 pixelů pro snadné ovládání a čtení a schopnost zobrazit 16 milionů barev.
Technologie 3G data, WiFi, BlueTooth, GPS přijímač, fotoaparát 3 Mpix, autofokus, diodový blesk.
Výdrž baterie minimálně 1 den a více.
3G internet.

samsung-s6102-galaxy-y-duos
139

drawBitmap createBitmap by array of colours Android example | drawbitmap-createbitmap-draw-bitmap-by-array-of-colours-android-example


public static Bitmap createBitmap (int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
public void drawBitmap (Bitmap bitmap, float left, float top, Paint paint)

//  //www.apache.org/licenses/LICENSE-2.0
public class MainActivity extends Activity {
	    private static final int WIDTH = 50;
	    private static final int HEIGHT = 50;
	    private static final int STRIDE = 64;   // must be >= WIDTH
	    
	    private static int[] createColors() {
	        int[] colors = new int[STRIDE * HEIGHT];
	        for (int y = 0; y < HEIGHT; y++) {
	            for (int x = 0; x < WIDTH; x++) {
	                int r = x * 255 / (WIDTH - 1);
	                int g = y * 255 / (HEIGHT - 1);
	                int b = 255 - Math.min(r, g);
	                int a = Math.max(r, g);
	                colors[y * STRIDE + x] = (a << 24) | (r << 16) | (g << 8) | b;
	            }
	        }
	        return colors;
	    }
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);

            int[] mColors = createColors();
            int[] colors = mColors;

           
            Bitmap bitmap = Bitmap.createBitmap(colors, 0, STRIDE, WIDTH, HEIGHT,
                    Bitmap.Config.RGB_565);
                      
			canvas.drawBitmap(bitmap, 50,20, paint); 
		}

	}
}


319

Unable to execute dex: Multiple dex files define Eclipse Android | unable-to-execute-dex-multiple-dex-files-define-eclipse-android


Try each step separately:


  1. Restart Eclipse

  2. Clean project and rebuild

  3. Create a new project and try it if the problem persists, if no move copy project to other folder, delete project from workspace , create new project same name and copy java, xml etc. files to new project

  4. Close Eclipse, backup folder c:\Users\myName\workspace\.metadata and delete it. Restart Eclipse try again import project to workspace


  5. Re-installing the Android Developer Tools


  6. Re-installing Eclipse - rename old folder with Android to Android_old, create new folder C:\Program Files\Android and copy new Eclipse with sdk into new folder


  7. Created a new project importing from the file system


  8. Created a new project from subversion



386

ArrayList Sublist Join Compare Loop Synchronize HashMap Sort Tree | arraylist-sublist-join-compare-loop-synchronize-hashmap-sort-tree




Editace Jana Žákovská : 2011-11-13 20:49:14
Počet článků v kategorii: 397
Url:rounded-rect-rectf-android-example
Share
Share
Tweet