android中如何将int颜色代码转换成十六进制
天蓬老师
天蓬老师 2017-04-17 17:40:32
0
3
1040

代码是这样:setBackgroundColor(0x33ffffff);、
但是xml文件就不能写0x...
xml文件是这样:<solid android:color="#33ffffff" />

我想把0x33ffffff转换成# 开头的颜色,我尝试过直接去掉0x换成#,发现颜色不一样,网上也查不到方法,最多只能查到十六进制转RGB,或者RGB转十六进制。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(3)
左手右手慢动作

The color conversion is correct, it is probably a problem of control transparency overlay. If there is no transparency, there will be no color difference.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#33FFFFFF" >

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#33FFFFFF"
        android:text="@string/hello_world"
        android:textColor="#33FFFFFF" />

</RelativeLayout>

This code is loaded directly, you will find that the background color of the textview has a prominent piece

迷茫

0x33ffffff is also hexadecimal, look for the conversion algorithm or corresponding software conversion

大家讲道理

Please use the Color.parseColor("#33ffffff") method to get the converted value, and then set it to the background

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template