You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android中如何动态设置颜色透明度(10%-100%)?

Dynamic Transparent Hex Color Generation for #bf6116

Got it, let's walk through exactly how to generate the transparent hex color you need based on your requirements.

Core Concept

The standard 8-digit hex color format is #<transparency-value><base-color-hex>. Your base color is #bf6116 (so the base hex string without the # is bf6116), and you just need to prepend the corresponding transparency hex value from your provided mapping to get the final color.

Transparency to Hex Mapping (Your Provided Values)

Here's the mapping clearly laid out for quick reference:

  • 100% — FF
  • 95% — F2
  • 90% — E6
  • 85% — D9
  • 80% — CC
  • 75% — BF
  • 70% — B3
  • 65% — A6
  • 60% — 99
  • 55% — 8C
  • 50% — 80
  • 45% — 73
  • 40% — 66
  • 35% — 59
  • 30% — 4D
  • 25% — 40
  • 20% — 33
  • 15% — 26
  • 10% — 1A
  • 5% — 0D
  • 0% — 00

Example Calculations

Let's apply this to your base color #bf6116:

  • 10% transparency: Take 1A → Final color: #1Abf6116 (note: hex is case-insensitive, so #1abf6116 works too)
  • 20% transparency: Take 33 → Final color: #33bf6116
  • 75% transparency: Take BF → Final color: #bfbf6116
  • 0% transparency: Take 00 → Final color: #00bf6116 (fully transparent)

Quick Cheat Sheet for Your Base Color

For easy lookup, here are the final colors for common transparency levels:

  • 10% → #1Abf6116
  • 20% → #33bf6116
  • 30% → #4Dbf6116
  • 40% → #66bf6116
  • 50% → #80bf6116
  • 60% → #99bf6116
  • 70% → #B3bf6116
  • 80% → #CCbf6116
  • 90% → #E6bf6116
  • 100% → #FFbf6116 (same as original #bf6116 since 100% opacity means no transparency)

If you're implementing this in code (say JavaScript), a simple function could handle this dynamically:

function getTransparentColor(transparencyPercent) {
  const transparencyMap = {
    100: 'FF', 95: 'F2', 90: 'E6', 85: 'D9', 80: 'CC',
    75: 'BF', 70: 'B3', 65: 'A6', 60: '99', 55: '8C',
    50: '80', 45: '73', 40: '66', 35: '59', 30: '4D',
    25: '40', 20: '33', 15: '26', 10: '1A', 5: '0D', 0: '00'
  };
  const baseColor = 'bf6116';
  const transparencyHex = transparencyMap[transparencyPercent];
  return `#${transparencyHex}${baseColor}`;
}

// Usage: getTransparentColor(10) → "#1Abf6116"

内容的提问来源于stack exchange,提问作者Vanraj Ghed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:35:34