What is the use of 0xff -colors in android?

Sometimes Android projects have color formats such as "0xff4ca665".

What is the purpose of using them?

+4
source share
3 answers

Some programmers have more experience with explicit 24-bit colors. And sometimes it matters in Android, alpha is not masked in some more direct manipulations in renderscript. And how do you want โ€œ0xff4ca665โ€ to tell the system that you want โ€œ0x4ca665โ€, and hoping that something else will mask it correctly, it looks like a fragmentary bet that literally can't even break the hour loop.

โ€‹โ€‹, View.setBackgroundColor(int), int 32- .

, - 24- . 32- 0bAAAAAAAARRRRRRRGGGGGGGGGBBBBBBBB. , RGB 8 , 8- , PorterDuff, . Android , - , , .

, 0xAARRGGBB, AA ff, 255, . , . , , 00, . , , , .

Android , , . 4444, 4 . 565, 5 , 6 5 . 16 , 32. 8888, , , , .

+4

, #ff4ca665... ARGB.

XML, ff , .

0xff4ca665 Java.

body {
  background: #4ca665;
}
Hide result
+2

Some Android APIs, such as View.setBackgroundColor (), expect integer colors in ARGB format colors. Thus, it 0xff4ca665indicates a fully opaque RGB color #4ca665, while an integer 0x4ca665is equal 0x004ca665and, therefore, means a fully transparent color.

+2
source

Source: https://habr.com/ru/post/1650599/


All Articles