2014-07-01 23 views
5

Esiste un metodo basato sul sistema per chiamare uno di questi selettori di colori, come nell'app Google Calendar? O ce l'ho per costruirlo da solo?Google Calendar color picker

enter image description here

+0

cosa vuoi per il selettore colori? –

+0

c'è un selettore di colori Android http://code.google.com/p/android-color-picker/ –

+0

http://v4all123.blogspot.ie/2013/06/simple-colorpicker-for-android.html –

risposta

5

è necessario utilizzare Color Picker Collection.

Implementazione:

ColorPickerDialog colorcalendar = ColorPickerDialog.newInstance(
       R.string.color_picker_default_title, 
       mColor, 
       mSelectedColorCal0, 
       5, 
       Utils.isTablet(this)? ColorPickerDialog.SIZE_LARGE : ColorPickerDialog.SIZE_SMALL); 

    //Implement listener to get selected color value 
    colorcalendar.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener(){ 

       @Override 
       public void onColorSelected(int color) 
       { 
        // ADD MARKER 
        Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_mobileedge_navpoint); 
        bmp = changeBitmapColor(bmp, color); 

        googleMap.addMarker(new MarkerOptions() 
        .position(latLng) 
        .title("My Spot") 
        .snippet("This is my spot!") 
        .icon(BitmapDescriptorFactory.fromBitmap(bmp))); 
       } 

    }); 

    colorcalendar.show(getFragmentManager(),"cal"); 

funzione per cambiare il colore bitmap:

private Bitmap changeBitmapColor(Bitmap sourceBitmap, int color) { 

     Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, 
       sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1); 
     Paint p = new Paint(); 
     ColorFilter filter = new LightingColorFilter(color, 1); 
     p.setColorFilter(filter); 

     Canvas canvas = new Canvas(resultBitmap); 
     canvas.drawBitmap(resultBitmap, 0, 0, p); 

     return resultBitmap; 
    } 

ho provato e ha funzionato bene! Il marcatore deve essere tutto bianco con alfa, solo allora i colori saranno perfetti!

+0

Può elaborare per favore lo stesso – prat

+0

@prat elaborare cosa? – extmkv

+0

Ho anche lo stesso requisito di cui sopra. La biblioteca che hai dichiarato corrisponde alla mia esigenza. Per favore, aiutami a usare la libreria? – prat

Problemi correlati