快速連結

2013年7月22日

背景圖無限重複祕技

使用以下圖片,拼成滿版背景的方法

在APP內拼成花花的背景:


2013年7月10日

讓你的View動起來──新版本

在4.0之前,讓View動作的語法如下:

    UIButton *button = [[UIButton alloc] init];
    CGRect frame = button.frame;
    frame.origin.x = 500; // new x coordinate
    frame.origin.y = 500; // new y coordinate

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration: 0.25];
    button.frame = frame;
    button.alpha = 0;
    [UIView commitAnimations];

2013年5月21日

對每個child作class確認

以下是程式碼:

for (var i:uint = 0; i < this.numChildren;i++){
  var child = this.getChildAt(i);
  if (child is SimpleButton){
     trace(child,"is SimpleButton");
  }
}

2013年3月2日

取得網址的參數


$.urlParam = function(name){
 var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
 if (!results) { return 0; }
 return results[1] || 0;
}


來源:Get URL Parameters with jQuery | Improved

2013年2月26日

改‧TouchImageView

原本我使用的版本找不到了,類似的在此:Pinching Zoom in android Image View or Bitmap
另外一個的版本則是這個:MikeOrtiz / TouchImageView
WrapMotionEvent與EclairMotionEvent程式碼我就沒有放上來了,直接到第一個連結複製即可。
我這裡參考許多文章,在TouchImageView.java內增加了放大縮小、邊界判定。

2013年2月23日

讓ViewGroup建立實體物件

當想要建立ViewGroup物件時,卻發現不能用ViewGroup直接建立物件,因為他是abstract(抽象)類型,必須要再建立一個實體類別去繼承ViewGroup。
實體類別的程式碼下收:

2013年2月20日

合併兩張圖片吧

上一次那個沒用,我就用合併的方式。
這次有用了XD
我是用左右並排的方式,依照不同需要可以隨意更改新Bitmap的長寬~注意一下drawBitmap的數值就好!

private Bitmap mergeBitmap(Bitmap firstBitmap, Bitmap secondBitmap) {
        int newWidth = firstBitmap.getWidth() + secondBitmap.getWidth();
        Bitmap bitmap = Bitmap.createBitmap(newWidth, firstBitmap.getHeight(),
                firstBitmap.getConfig());
        Canvas canvas = new Canvas(bitmap);
        canvas.drawBitmap(firstBitmap, 0, 0, null);
        canvas.drawBitmap(secondBitmap, firstBitmap.getWidth(), 0, null);
        canvas.save(Canvas.ALL_SAVE_FLAG);//保存  
 canvas.restore();
        return bitmap;
}

在ImageView中一次顯示多張圖片的技巧

在ImageView中一次顯示兩張圖片的技巧,話說,我還沒成功過!(欸)
可是來源的討論串是有人成功囉!
來源:overlay two images in android to set an imageview

private DoubleImage(Bitmap bm1, Bitmap bm2){
  ImageView imgView = new ImageView(this);
  Drawable[] layers = new Drawable[2];
  layers[0] = new BitmapDrawable(getResources(),bm1);
  layers[1] = new BitmapDrawable(getResources(),bm2);
  LayerDrawable layerDrawable = new LayerDrawable(layers);
  imgView.setImageDrawable(layerDrawable);
}