Android – Animation – Hiệu ứng – Chuyển hoạt

Vị trí File XML:

res/anim/filename.xml

Resource reference (tên gọi):

In Java: R.anim.filename
In XML: @[package:]anim/filename

Thuộc tính chung:

  • android:fillAfter=”true” – Giữ trạng thái sau khi chạy (trong <set>)
  • android:fillBefore=”true” – Giữ trạng thái trước khi chạy
  • android:duration – Thời gian chạy
  • android:startOffset – Thời gian chờ trước khi chạy
  • android:repeatMode – Chế độ lặp
  • android:repeatCount – Lần lặp
  • infinite – lặp vô hạn
  • android:interpolator – (nội suy) kiểu chạy
    • @android:anim/accelerate_decelerate_interpolator – Tăng tốc, giảm tốc
    • @android:anim/accelerate_interpolator – Tăng tốc
    • @android:anim/anticipate_interpolator – (Biết trước) quay lên vị trí đầu, chạy tiếp
    • @android:anim/anticipate_overshoot_interpolator – (Biết trước_Vượt qua) quay lên vị trí đầu, vượt qua vị trí cuối
    • @android:anim/bounce_interpolator – (nẩy lên) nẩy lên ở vị trí cuối
    • @android:anim/cycle_interpolator – (Vòng tròn) chạy qua lại đầu, cuối
    • @android:anim/decelerate_interpolator – (Giảm tốc) Chậm dần
    • @android:anim/linear_interpolator – (Thẳng) đều đều
    • @android:anim/overshoot_interpolator – (Vượt qua) vượt qua vị trí cuối
    • @android:anim/fade_in
    • @android:anim/fade_out
    • @android:anim/slide_in_left – Chạy từ trái qua
    • @android:anim/slide_out_right – Chạy từ phải rồi mất

Alpha Animation (Độ trong suốt):


<alpha
android:duration="3000"

android:fromAlpha="0"
android:toAlpha="1" />

Rotate Animation (Độ xoay):


<rotate
android:duration="3000"

android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />

</div>

Scale Animation (Độ co dãn):


<scale
android:duration="3000"

android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="2"
android:toYScale="2" />

Translate Animation (Độ đi chuyển):


</div>
<translate
android:duration="3000"

android:fromXDelta="-50%"
android:fromYDelta="-50%"
android:toXDelta="0%"
android:toYDelta="0%" />

Set/Batch Animation (nhiều hiệu ứng):


<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/slide_out_right">

<alpha
android:duration="3000"

android:fromAlpha="0"
android:toAlpha="1" />

<rotate
android:duration="3000"

android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />

<scale
android:duration="3000"

android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="2"
android:toYScale="2" />

<translate
android:duration="3000"

android:fromXDelta="-50%"
android:fromYDelta="-50%"
android:toXDelta="0%"
android:toYDelta="0%" />

</set>

Gọi trong Code:

// Load hiệu ứng
final Animation amin = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out);
// Sự kiệnamin.setAnimationListener(new Animation.AnimationListener() {
    @Override    public void onAnimationStart(Animation animation) {

    }

    @Override    public void onAnimationEnd(Animation animation) {

    }

    @Override    public void onAnimationRepeat(Animation animation) {

    }
});
// Chạy hiệu ứng
txtMessage.startAnimation(amin);

Trích:

http://www.androidhive.info/2013/06/android-working-with-xml-animations/
http://developer.android.com/guide/topics/resources/animation-resource.html

Android Studio – Mẹo và Thủ thuật – Tips and Cheaps

Mở nhanh

Mở Class: Ctrl + N
Mở File: Ctrl + Shift + N
Mở Task: Alt + Shift + N

Di chuyển

Đến vị trí con trỏ cũ: Ctrl + Alt + Left/Right (làm gì xong về chỗ cũ)
Đến vị trí chỉnh sửa cũ: Ctrl + Shift + backspace
Android Studio LogoĐến biến khai báo: Ctrl + B = Ctrl + Click

Highlight Code: ctrl+shift+f7 (Hủy =esc)

Android Studio Logo

Chuyển con trỏ đến Methods, Inner Classes khác: alt+up/down

Android Studio Logo

Mở File Structure nhanh: Ctrl + F12 

Android Studio Logo

Xem cấp bậc Method (The Call Hierarchy Popup): ctrl+alt+h

Android Studio Logo

 Xem định nghĩa nhanh: ctrl+shift+iAndroid Studio Logo

Đóng hiện Nhóm code: ctrl+shift+plus/minus

Android Studio Logo

Bookmarks!

Toggle Bookmark: F11

Toggle Bookmark With Mnemonic: ctrl+f11

Nếu bookmark có số: ctrl+number

Show Bookmarks shift+f11

Android Studio Logo

Tìm Hành động trong menu: ctrl+shift+a

Android Studio Logo

Chuyển dòng lên xuống: alt+shift+up/down

Android Studio Logo

Xóa dòng: ctrl+y

Android Studio Logo

trích: http://www.developerphil.com/android-studio-tips-of-the-day-roundup-1/

Nhân đôi dòng (Duplicate): ctrl+d

Android Studio Logo

Tăng, Giảm vùng chọn: ctrl+w / ctrl+shift+w

Android Studio Logo

Rào (surround) hàm (thêm if, …): ctrl+alt+t

Android Studio Logo

Mở File gần đây: Ctrl + E, Ctrl + Tab

Android Studio Logo

Di chuyển Method: ctrl+shift+up/down

Android Studio Logo

  Hoàn thành Method, code nhanh, khỏi chuyển xuống cuối: ctrl+shift+enter

 Android Studio Logo

Kết hợp dòng: ctrl+shift+j

 Android Studio Logo

Chọn Nhanh vị trí trong (Structure, file…, bar): alt+f1

 Android Studio Logo

Unwrap/Remove: ctrl+shift+delete

 Android Studio Logo

 Toggle Breakpoints: Ctrl+F8

 Expand Shrink Selection

Đổi biến khi Debug: Right Click Breakpoint

Expand Shrink Selection

Tạo Log Debug: Nhấp Phải Breakpoint

Logging Breakpoints

Tạo Breakpoint Tạm: Ctrl+Alt+Shift+F8 = Alt+Left Click in the left gutter

Temporary Breakpoints

 Ẩn Breakpoint: Alt+Left Click on an existing breakpoint in the left gutter

Expand Shrink Selection

 Đính kèm hàm khi Debug: Build / Attach to Android Process

 Attach Debugger

Xem Biến nhanh qua cửa sổ (Evaluate Expression): Alt+F8

 Evaluate Expression

Xem giá trị biến (Inspect Variable): Alt+Left Click biến

Inspect Variable

Mark Object: right-click and select “Mark Object”

Mark Object

 Phân tích dữ liệu tại chỗ: Menu: Analyze → Analyze Data Flow to Here

Analyze Data flow to Here

Chọn nhiều, thay đổi nhiều dòng cùng lúc: Alt+J

Sublime Text Multi Selection

Chọn nhiều Cột: Alt+MouseDrag = Shift+Alt+Insert

Column Selection

Postfix Completion:

gợi ý từ khóa:

  • .for (for a foreach)
  • .format (wraps a string in String.format())
  • .cast (wraps a statement in a type cast)

 Postfix Completion

So sánh với Clipboard: right-click the selection and select Compare With Clipboard

Find action: compare with clipboard

Compare With Clipboard

 VCS Operation Popup: Alt+`

VCS Operations Popup

Compare With Branch (Git):

  • Menu (for git): VCS -> Git -> Compare With Branch
  • Find Actions: Compare With Branch
Compare With Branch (Git)

Trích: http://www.developerphil.com/android-studio-tips-of-the-day-roundup-4/

Enter vs Tab for Code Completion: enter or tab

Enter vs Tab for Code Completion

  • Return and keep panel open: Escape
  • Close panel and Return: Shift+Escape

Return to the Editor

Jump to Last Tool Window (F12)

Jump to Last Tool Window

Hide All Panels (Ẩn mọi Panels): Ctrl+Shift+F12

Hide All Panels

 Thông tin tham số trong Hàm (Parameter Info): Ctrl+P

 Parameter Info

Đổi Tab nhanh: Ctrl+Tab

The Switcher

 Thông tin hàm: Ctrl+Shift+Q, Ctrl + Q

Context Info

Trích: http://www.developerphil.com/android-studio-tips-of-the-day-roundup-5/

Refactor This:  Ctrl+Alt+Shift+T

 Refactor This

Mở file Liên quan (Related File): Ctrl+Cmd+Up

Related File

Extract Variable: Ctrl+Alt+V

Extract Variable

Extract Parameter: Ctrl+Alt+P

  Extract Parameter

Extract Method: Ctrl+Alt+M

 Extract Method

Gom dòng (Inline): Ctrl+Alt+M

Inline

Đổi tên:  Shift+F6

Rename

Pull Up / Push Down: Ctrl+Alt+Shift+T and choose pull members up / push members down

 Pull Up / Push Down

Trích: http://www.developerphil.com/android-studio-tips-of-the-day-roundup-6/

Android Studio – Cài đặt Cho Code

Đổi giao diện:

1: theme trắng đen
2: font chữ chương trình
3: hiện thanh Heap, giống xóa Ram
4: Hiện thanh bên trái (Project, Structure) rộng hơn, thanh thông tin hẹp lại (Info, error)
5: font chữ chế độ Presentation (Hiện ra to hơn, dễ nhìn)

Chỉnh Menu & Toolbar:

 Code thông minh hơn: (chọn None) hiện ra không cần check chữ đầu tiên

Code Font:

Tắt kiểm tra chính tả:

Thêm từ điển kiểm tra chính tả:

  1. Go to Settings -> Spelling -> Dictionaries
  2. Click +
  3. Select path to your dictionaries folder (inside you must have plaintext word lists with .dic extension)
  4. Restart Android Studio

Android Studio – Phím tắt Code

  • Menu Edit

    Undo = Ctrl + Z > Quay lại
    Redo = Ctrl + Shift + Z > Quay ngược lại
    Copy = Ctrl + C
    Cut = Ctrl +X
    Paste = Ctrl + V
    Find/
    Find = Ctrl + F > tìm trong văn bản,
    Replace = Ctrl + R > thay đổi trong văn bản
    Find in Path = Ctrl + Shift + F >Tìm trong tất cả văn bản
    Replace in Path = Ctrl + Shift + R > đổi trong tất cả văn bản
    Find Usages = Alt + F7 > Tìm Hàm Sử dụng (Cần khi tìm hàm nhanh)
    Select All = Ctrl + A > Chọn hết
    Extend Selection = Ctrl + W > Tăng lựa chọn
    Shirnk Selection = Ctrl + Shift + W > Giảm lựa chọn
    Complete Current Statement = Ctrl + Shift + Enter > Kết thúc dòng (Xuống dòng nhanh)
    Duplicate Block = Ctrl + D > Nhân bản dòng
  • Menu View

    Enter Presentation Mode > Hiện giao diện lớn (Chữ lớn hơn, Dễ nhìn hơn)
    Enter Full Screen > Toàn màn hình
  • Menu Navigate

    Class = Ctrl + N > Đến lớp
    File = Ctrl + Shift + N > Đến file
    Line =  Ctrl + G > Đến dòng
    Back = Ctrl + Alt + Left > Đến vị trí con trỏ cũ (mới đổi giá trị xong, về vị trí cũ)
    Forward = Ctrl + Alt + Right > Đến vị trí con trỏ tiếp
    Bookmarks
    Toggle Bookmark = F11 > Thêm, xóa bookmark (lưu vị trí code, Có thể thay thế = code lỗi, hay Todo)
    Show Bookmark = Shift + F11
    Select In = Alt + F1 > Vị trí code Trong (Hiện ra list chọn để đến vị trí của file, Constructor…)
    Declaration = Ctrl + B = Hold Ctrl + Click > Đến vị trí Khai báo Biến, hàm
    Implementations = Ctrl + Alt + B > Tìm Implement Code
    Type Structure = Ctrl + F12 > Mở Construre nhanh để đến phương thức
    Next Hightlighted Error = F2
    Previous Hightlighted Error = Shift + F2
    Next Method = Alt + Down
    Previous Method = Alt + Up
  • Menu Code

    Override Methods = Ctrl + O > Tạo hàm Ghi đè
    Implement Methods
    Deleate Methods
    Generate… = Alt + Insert > Tạo hàm nhanh, Constructor, Get, Set
    Surround With = Ctrl + Alt + T > Bao bọc code với (region, …)
    Completion > Code tự động hoàn thành
    Basic = Ctrl + Space > Gợi ý code Bình thường
    SmartType = Ctrl + Shift + Space > Gợi ý thông minh
    Cyclic Expand Word = Alt + Slash > Gợi ý (tuần hoàn) Theo dòng trước
    Cyclic Expand Word (Backward) = Alt + Shift + Slash > gợi ý theo dòng sau
    Folding
    Expand = Ctrl + NumPad+ > Hiện Code đã thu gọn
    Collapse = Ctrl + NumPad- > Hiện Code
    Expand Recursively = Ctrl + Alt ++ > Mở rộng đệ quy
    Collapse Recursively = Ctrl + Alt + – > Hiện code Đệ quy ( thu gọn, thu gọn cha)
    Expand All = Ctrl + Shift ++ > Hiện tất cả code đã thu gọn
    Collapse All = Ctrl + Shift +- > Ẩn tất cả Code
    Expand doc Comments > Hiện Comment
    Collapse doc Comments > Ẩn Comment
    Fold Selection/ Remove region = Ctrl + Period
    Fold Code Block = Ctrl + Shift + Period
    Insert Live Tempate = Ctrl + J > Chèn code Tempate
    Comment with Line Comment = Ctrl + Slash > Comment // theo dòng
    Comment with Block Comment = Ctrl + Shift + Slash > Comment /* */ theo nhóm
    Reformat Code = Ctrl + Alt + L > Định dạng lại code (cho Đẹp)
    Auto Indent Lines = Ctrl + Alt + I > Tự động tab dòng đúng (4 space, 8 Space)
    Optimize Import = Ctrl + Alt + O > Sửa Import ( thêm, xóa không dùng)
    Rearrange Code = Sắp lại code ???
    Move Statement Down = Ctrl + Shift + Down > Di chuyển cả hàm xuống
    Move Statement Up = Ctrl + Shift + Up
    Move Line Down = Alt + Shift + Down > Di chuyển dòng xuống
    Move Line Up = Alt + Shift + Up
    Update Copyright
  • Menu Analyze

  • Menu Refactor (Cấu trúc lại, sửa code nhanh)

    Refactor This = Ctrl + Alt + Shift + T
    Rename = Shift + F6 > Đổi tên
    Rename File > Đổi tên File chứa
    Change Signature = Ctrl + F6
    Move = F6
    Copy = F5
    Save Delete = Alt + Delete
    Extract/
    Variable = Ctrl + Alt + V
    Constant = Ctrl + Alt + T
    Field = Ctrl + Alt + F
    Parameter = Ctrl + Alt + P
    Functional Parameter = Ctrl + Alt + Shift + P
    Method = Ctrl  + Alt + M
    Encapsulate Fields
    Generify
    Migrate
  • Đổi Tab nhanh: Ctrl + Tab

Ctrl + Tab: Đổi nhanh File & Control Windows
Giữ Ctrl + Up (Down, Tab, Shift+Tab, Alt) Để điều hướng.
Delete of BackSpace để đóng Tab

Search Any Where, tìm kiếm mọi thứ: SHIFT + SHIFT

Hiện thông tin hàm = Ctrl + Q

View | Quick Documentation

Cuộn chiều ngang: Giữ Shift

So sánh 2 thư mục: Ctrl + D

Chọn 1 hay 2 thư mục trong Project + Ctrl + D

Debug/ Run:

Chạy luôn (resume program): F9
Dừng Debug (Stop “app”): Ctrl + F12
Chạy xuống dòng tiếp theo (Step Over): F8
Chạy vào hàm (bug tiếp code): F7
Hiện cửa sổ thông tin biến (Evalation Express): Alt + F8
Xem giá trị biến (Inspect Variable): Alt+Left Click biến