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.

Create monochromatic bitmap Android example


AD MOB


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);
             paint.setColor(Color.BLUE);
            
           Canvas c = new Canvas(b);
           c.drawRect(0, 0, 200, 200, paint);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}



monochromatic bitmap

397LW NO topic_id




AD

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();
            }
        });	
 	}

}

194

SAMSUNG i9220 Galaxy Note | samsung-i9220-galaxy-note


Displej 1280 x 800, 5.3 "
Rozměry 146.85 mm x 83 mm x 9.7 mm
Rozlišení fotoaparátu 8 Mpix
HD video, natačení videosekvencí
Operační system Android
Hlasové ovládání
Přehrávání MP3
Baterie Li-Ion ,doba hovoru 1570 min
Frekvence procesoru 1.4 GHz
Uživatelská paměť 16000 MB
Datové funkce: GPS modul, WiFi, Bluetooth, GPRS, EDGE, HSCSD, Hardwarový modem, Infraport
Podporované sítě GSM&EDGE 850 / 900 / 1.800 / 1.900
Formát videosouborů 3GPP / H.263 / H.264 / MPEG4 / WMV

samsung-i9220-galaxy-note
285

Unable to resolve target android | unable-to-resolve-target-android


Unable to resolve target android-7
Try this solution:
Select project from tree (project explorer)
- right click on project
- properties
- select Android from tree
- change Project Build Target to higher (or change project build target)
- selct from menu: Project-Clean ( select your project - OK)
71

For cycle loop in Java example | for-cycle-loop-in-java-example


Cycle for in Java example

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "Hello", "people", "hello", "world!" };

		for (int i = 0; // start position , first cycle i == 0
                      i < arrayOfString.length; // if i < 4 (length of array) do loop
                       i++ // incrementation after cycle
                       ){
			System.out.println(arrayOfString[i]); 
                       // i++ incrementation
		}
	}
}

365

layout-sw600dp values-sw600dp Android example of use | layout-sw600dp-values-sw600dp-android-example-of-use


Why the app selects data from basic layout folder if smallest width is higher then the number in folder name?
Example 1
layout-sw600dp values-sw600dp (smallest width sw for data usage from this folder is 600dp density independent pixel!!!!!)
Device screen resolution is 1200 x 900 px (pixel) Wow, app to be select data from sw600dp folder! Realy?
DPI of device screen - dot per inch (pixel per inch) is 480 pixel it is wery important number!


  1. App selects smallest dimension of screen. In our case 900 px
    Medium screen have 160 dpi (The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen.).


  2. App calculate ratio 480 / 160 = 3 (The conversion of dp units to screen pixels: px = dp * (dpi / 160))


  3. App calculate smallest dimesnion of screen in dp 900 / 3 = 300 dip or dp (density independed pixel).


  4. App selects data from basic values and layout folder because sw600dp is greater than 300dp.





In our case smallest dimension of screen must be at least 1800 real - physical pixels (1800 px / 3 ratio(dpi/160) = 600 dp (dip density independend pixels) to be used data from folders values-sw600dp and layout-sw600dp.


Example 2 see Example 1 abouve
Device: Nexus 7 (2012) selected from Android Studio tool layout editor
Resolution: 800x1280 px
DPI: tvdpi (approximately 213dpi)
Ratio: 1.33 (213 / 160)
Smallest width in px: 800
Convert px to dp: 601.5 (800 / 1.33)
Result:Smallest width is 601.5dp The App to be used data from folders values-sw600dp and layout-sw600dp.


Editace: 2013-12-09 13:10:11
Počet článků v kategorii: 397
Url:create-monochromatic-bitmap-android-example

AD
11 Share
Share
Tweet