Convert hex color value ( #ffffff ) to integer value

前端 未结 9 1053
孤城傲影
孤城傲影 2020-12-13 01:26

I am receiving hex color values from a server (in this form, #xxxxxx , example #000000 for black)

How do I convert this to an integer value

9条回答
  •  遥遥无期
    2020-12-13 02:04

    Get Shared Preferences Color Code in String then Convert to integer and add layout-background color:

        sharedPreferences = getSharedPreferences(mypref, Context.MODE_PRIVATE);
        String sw=sharedPreferences.getString(name, "");
        relativeLayout.setBackgroundColor(Color.parseColor(sw));
    

提交回复
热议问题