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.

Android Xml Tags Samples

397LW NO topic_id

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


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;
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(new SampleView(this));

	private static class SampleView extends View {

		public SampleView(Context context) {

		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();

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

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



Chrome youtube shockwave flash plugin crashes solution | chrome-shockwave-flash-plugin-crashes

Google Chrome and Shockwave Flash crashes on youtube.com

  • open chrome://plugins/ with Google Chrome

  • click on Plus button for more details

  • find Flash (3 files)
  • disable two other Shockwave Flash

  • for more see image below



Set theme of AdActivity to @android:style/Theme.Translucent | set-theme-of-adactivity-to-androidstyletheme-translucent


<activity android:name="com.google.android.gms.ads.AdActivity"
              android:theme="@android:style/Theme.Translucent" />


Rename Android project package issue in Eclipse - R cannot be resolved to a variable | rename-android-project-package-issue-in-eclipse

Issue: After after renaming package this problem occurred "R cannot be resolved to a variable".

Solution: Try Clean your project Project » Clean » Clean projects selected below » select your project and click OK.

Try to delete the invalid code and type it again:

LinearLayout layout = (LinearLayout) findViewById(R.id.layout); // delete R.id.layout
LinearLayout layout = (LinearLayout) findViewById(); 
LinearLayout layout = (LinearLayout) findViewById(R.id.layout); // re-write this code R.id.layout

Android Studio reduce memory usage of PC | android-studio-reduce-memory-usage

File->Settings->Plugins and disable some plugins:

  • Google Cloud Testing

  • Google Cloud Tools Core

  • Google Cloud Tools for Android Studio

  • CVS Integration

  • Git Integration

  • GitHub

  • hg4idea

  • Subversion Integration

Use Emulator AVD with small memmory usage. For example: Virtual tablet with hight resolution have big memmory usage. Virtual phone with 240x320 resolution have small memmory usage.

Use instaed of Emulator, real device connected by USB (smarphone Samsung Galaxy or other recommended by Google whit debugable mode).

If you notice that Android Studio works slowly, consider the possibility to reduce the number of folders under antivirus protection.
Each antivirus check in your project consumes resources. You can significantly improve the performance, if you exclude certain folders from the antivirus protection.

Editace: 2012-01-26 19:35:57
Počet článků v kategorii: 397