Re: ImageView setColorFilter, what to do for a bitmap?

by Tim Jones » Sun, 03 Apr 2011 01:54:04 GMT


Sponsored Links
 You can create a new scratch bitmap with a copy of the data and then blt it 
back onto the target bitmap like so:

Paint p = new Paint();

 p.setColorFilter(<customColorFilter>);
 Canvas c = new Canvas(target);
c.drawColor(Color.BLACK);
c.drawBitmap(scratchBitmap, 0, 0, p);

-- 



Other Threads

1. How to make LinearLayout smooth scroll ingé”›

hi, i am a new android developer, and recently I was doing a
horizontal scrolling menu. the follow is xml doc:

   <com.kingkong.gallery.GalleryHorizontalView
                android:id="@+id/HorizontalScrollView01"
                android:layout_width="fill_parent" android:scrollbars="none"
                android:layout_height="wrap_content">
                <LinearLayout android:id="@+id/ourlayout"
                        android:orientation="horizontal" 
android:layout_width="fill_parent"
                        android:layout_height="fill_parent" 
android:background="#ffffff">
                </LinearLayout>
   </com.kingkong.gallery.GalleryHorizontalView>

 class GalleryHorizontalView is defined by myself, it is extends from
HorizontalScrollView.
in GalleryHorizontalView, I made the following changes  ( changes in
method onTouchEvent(MotionEvent ev) ):


  case MotionEvent.ACTION_MOVE:
                                                // x == ev.getX();
                        final int deltaX = (int) (mLastMotionX - x);
                        mLastMotionX = x;
                                            // i want to let the child
view's ( LinearLayout ) horizontal padding change,so change
                                            //the child view's x
coordinate, x coordinate is change by deltaX;
                        if (deltaX < 0) {
                                if (getScrollX() >= 0) {
                                        getChildAt(0).scrollBy(deltaX, 0);
                                }
                        } else if (deltaX > 0) {
                                final int rightEdge = getWidth() - 
getPaddingRight();
                                final int availableToScroll = 
getChildAt(0).getRight()
                                                - getScrollX() - rightEdge;
                                if (availableToScroll > 0) {
                                        
getChildAt(0).scrollBy(Math.min(availableToScroll, deltaX),
                                                        0);
                                }
                        }
                        break;

case MotionEvent.ACTION_UP:
                                                int menuItemWidth =
80;
                        int temp = getChildAt(0).getScrollX();
                        int remainder = temp %menuItemWidth;
                        int scrollToCoords = 0;
            // if temp <0 or temp == the child view's  left
coordinate, scrollToCoords =0;
            //scrollToCoords's value is x coordinate when the child
view end its scrolling.
            //the follow calculation is to ensure that each option can
be displayed properly

                        if (temp < 0 || temp == getChildAt(0).getLeft()) {
                                scrollToCoords = 0;
                        } else if (temp >= getChildAt(0).getRight() / 2) {
                                scrollToCoords = getChildAt(0).getWidth() / 2;
                        } else if (temp < getChildAt(0).getRight()
                                        && temp > getChildAt(0).getLeft()) {
                                if (remainder == 0) {
                                        scrollToCoords = temp;
                                } else {
                                        if (remainder > menuItemWidth/2) {
                                                scrollToCoords =
 
temp - remainder + menuItemWidth;
                                        }
                                        if (remainder <= menuItemWidth/2) {
                                                scrollToCoords = temp - 
remainder;
                                        }
                                }
                        }
                        float mDeltaX = mLastMotionX - x;
                        mScroller.startScroll((int)mLastMotionX, 0, (int)x, 0, 
1000);
                        this.invalidate();
                        getChildAt(0).scrollBy((int) mDeltaX, 0);
                        getChildAt(0).scrollTo(scrollToCoords, 0);



i run my app after made this change,the child view LinearLayout can
scroll with the order, but it looks like jump,
not  smooth scrolling, how can make the scroll smooth.

thanks very much.



--~--~---------~--~----~------------~-------~--~----~

2. android.os.Build.MANUFACTURER

Is this no longer available?   I find it here:
http://developer.android.com/reference/android/os/Build.html#MANUFACTURER  but
when I try to use eclipse just gives me an error.
The reason I am looking for something like this is to make my unique id
something more substantial.   Since it appears
that android.provider.Settings.Secure.ANDROID_ID cannot be trusted to give
back a 16 digit hex number and the IMEI is probably not on devices without
phone guts I am trying to create my own.   I was going to use the
manufacturer since I would assume that each one would burn a unique
ANDROID_ID into the device but it does not seem to be there anymore.  I
suppose I could use the android.os.Build.PRODUCT if it is going to be around
for successive builds.

Wayne

-- 
Writing code is one of few things
that teaches me I don't know everything.

http://www.fuligin.com

--~--~---------~--~----~------------~-------~--~----~

3. Help! Trying to get Basic Auth working with WebView. setHttpAuthUsernamePassword?

4. listview color

5. icons

6. mapmode

7. Temp storage for bitmap