質問

だから私は活動の背景色を取得するコードの次のコードを持っています。ただし、getColorはint値を返し、これを変更する方法はありません。

    setContentView(R.layout.activity_test);

    View root = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);

    int color = Color.TRANSPARENT;
    Drawable background = root.getBackground();
    if (background instanceof ColorDrawable)
        color = ((ColorDrawable) background).getColor();
.

この特定の場合では、アクティビティの背景色は、最初はgetColor()が-16737844として返されるXMLファイル内のandroid:background="#0099cc"と定義されています。ただし、時間の経過とともに色のRGB値を徐々に変更するようなものをすることで、それを変更したいです[すなわちRGB(InitialRval + 1、InitialGVAL + 1、InitialBVAL + 1)]。これには、何組のRGB値にCONVERD -16737844がCONVERCOR COVENTS-16737844を必要としますが、そうする手段はないようです。

役に立ちましたか?

解決

16進カラー値をRGBに変換したい。

int red = (color >> 16) & 0xFF;
int green = (color >> 8) & 0xFF;
int blue = (color >> 0) & 0xFF;
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top