有没有办法从另一个图像源中选择某种颜色并在没有第 3 方程序的情况下使用它?
Is there a way to pick a certain colour from another image source and use it without a 3rd party program?
我在 XML 中的很多作品都有多种颜色可供选择,我似乎找不到 Android Studio 的扩展程序或插件可以从图像源中选择颜色我自己选择并在我的代码中应用它。我目前正在使用 Photoshop,但不幸的是,它 降低了我的计算机速度 。
我一直在使用原生颜色,而不是我自己的颜色。例如:
<< ? xml version = "1.0"
encoding = "utf-8" ? >
<
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 = "@color/color_bg"
tools: context = "com.transcendencetech.juliospizzaprototype.SignInActivity" >
<
include
android: id = "@+id/header"
layout = "@layout/header"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: layout_alignParentTop = "true"
android: layout_alignParentLeft = "true"
android: layout_alignParentStart = "true" / >
<
RelativeLayout
android: id = "@+id/my_tabs"
android: layout_width = "match_parent"
android: layout_height = "40dp"
android: layout_below = "@id/header"
android: background = "@android:color/black" >
<
View
android: id = "@+id/divider_view"
android: layout_width = "1dp"
android: layout_height = "match_parent"
android: layout_centerInParent = "true"
android: layout_margin = "2dp"
android: background = "@android:color/white" / >
<
Button
android: id = "@+id/pizza_list_bt"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_alignParentLeft = "true"
android: layout_alignParentStart = "true"
android: layout_toLeftOf = "@id/divider_view"
android: layout_toStartOf = "@id/divider_view"
android: background = "@android:color/black"
android: inputType = "textPersonName"
android: text = "List of Pizzas"
android: textColor = "@android:color/white" / >
<
Button
android: id = "@+id/deals_list_bt"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_alignParentEnd = "true"
android: layout_alignParentRight = "true"
android: layout_toEndOf = "@id/divider_view"
android: layout_toRightOf = "@id/divider_view"
android: background = "@android:color/black"
android: inputType = "text"
android: text = "List of Deals"
android: textColor = "@android:color/white" / >
<
/RelativeLayout>
<
ImageView
android: id = "@+id/pizza_list_iv"
android: layout_width = "match_parent"
android: layout_height = "150dp"
android: layout_below = "@id/my_tabs"
android: scaleType = "fitXY"
android: src = "@drawable/list_pizza_header" / >
<
ListView
android: id = "@+id/list_view"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: layout_below = "@id/pizza_list_iv"
android: divider = "@color/color_divider"
android: focusable = "true"
android: dividerHeight = "2dp"
android: layout_margin = "15dp" / >
<
include
layout = "@layout/footer"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: layout_alignParentBottom = "true"
android: layout_alignParentLeft = "true"
android: layout_alignParentStart = "true" / >
<
/RelativeLayout>
如果您的意思是要使用滴管工具测量十六进制值(例如#ff0000)或RGB值(例如rgb(255 , 0, 0)) 的特定像素,有许多网站允许您这样做。
例如,如果您在网络上搜索“来自图像的在线颜色选择器”,会出现许多不错的网站。我使用出现在 Google、Image Color Picker 上的第一个(您可以找到自己的),它可以让您从网络 URL 中选择图像 [=26] =] 或 从您的计算机上传图像。
希望对您有所帮助!
第一步:定义一个或多个颜色资源,如res/values/colors.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#3f51b5</color>
<color name="primary_dark">#1a237e</color>
<color name="accent">#ffee58</color>
</resources>
第 2 步:单击出现在资源编辑器边栏中资源左侧的色样:
单击该样本将弹出一个颜色选择器对话框:
第 3 步:单击该对话框中色样栏左侧的吸管工具。这将调出跟随鼠标指针的典型滴管视图。将鼠标悬停在要拾取的颜色上,然后单击鼠标左键。返回对话框,单击“选择”以更新颜色资源以使用选择的颜色。
第 4 步:在您的布局中,使用 @color/whatever_name_you_give_it
来引用颜色,其中 whatever_name_you_give_it
是您为其指定的任何名称。
有很多网站可以帮助您选择图像颜色。我个人使用 pickimagecolor.com,因为您甚至可以找到使工作更轻松的颜色阴影。它允许您从计算机上传图像,您可以轻松找到十六进制、RGB() 颜色和 HSV 颜色代码。我只是复制颜色代码并使用它。这是一个图像颜色选择器网站,但您也可以使用它来将颜色代码 Hex 转换为 RGB 、 RGB 到 HEX 以及更多可用选项。希望对你有帮助。
我在 XML 中的很多作品都有多种颜色可供选择,我似乎找不到 Android Studio 的扩展程序或插件可以从图像源中选择颜色我自己选择并在我的代码中应用它。我目前正在使用 Photoshop,但不幸的是,它 降低了我的计算机速度 。
我一直在使用原生颜色,而不是我自己的颜色。例如:
<< ? xml version = "1.0"
encoding = "utf-8" ? >
<
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 = "@color/color_bg"
tools: context = "com.transcendencetech.juliospizzaprototype.SignInActivity" >
<
include
android: id = "@+id/header"
layout = "@layout/header"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: layout_alignParentTop = "true"
android: layout_alignParentLeft = "true"
android: layout_alignParentStart = "true" / >
<
RelativeLayout
android: id = "@+id/my_tabs"
android: layout_width = "match_parent"
android: layout_height = "40dp"
android: layout_below = "@id/header"
android: background = "@android:color/black" >
<
View
android: id = "@+id/divider_view"
android: layout_width = "1dp"
android: layout_height = "match_parent"
android: layout_centerInParent = "true"
android: layout_margin = "2dp"
android: background = "@android:color/white" / >
<
Button
android: id = "@+id/pizza_list_bt"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_alignParentLeft = "true"
android: layout_alignParentStart = "true"
android: layout_toLeftOf = "@id/divider_view"
android: layout_toStartOf = "@id/divider_view"
android: background = "@android:color/black"
android: inputType = "textPersonName"
android: text = "List of Pizzas"
android: textColor = "@android:color/white" / >
<
Button
android: id = "@+id/deals_list_bt"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_alignParentEnd = "true"
android: layout_alignParentRight = "true"
android: layout_toEndOf = "@id/divider_view"
android: layout_toRightOf = "@id/divider_view"
android: background = "@android:color/black"
android: inputType = "text"
android: text = "List of Deals"
android: textColor = "@android:color/white" / >
<
/RelativeLayout>
<
ImageView
android: id = "@+id/pizza_list_iv"
android: layout_width = "match_parent"
android: layout_height = "150dp"
android: layout_below = "@id/my_tabs"
android: scaleType = "fitXY"
android: src = "@drawable/list_pizza_header" / >
<
ListView
android: id = "@+id/list_view"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: layout_below = "@id/pizza_list_iv"
android: divider = "@color/color_divider"
android: focusable = "true"
android: dividerHeight = "2dp"
android: layout_margin = "15dp" / >
<
include
layout = "@layout/footer"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: layout_alignParentBottom = "true"
android: layout_alignParentLeft = "true"
android: layout_alignParentStart = "true" / >
<
/RelativeLayout>
如果您的意思是要使用滴管工具测量十六进制值(例如#ff0000)或RGB值(例如rgb(255 , 0, 0)) 的特定像素,有许多网站允许您这样做。
例如,如果您在网络上搜索“来自图像的在线颜色选择器”,会出现许多不错的网站。我使用出现在 Google、Image Color Picker 上的第一个(您可以找到自己的),它可以让您从网络 URL 中选择图像 [=26] =] 或 从您的计算机上传图像。
希望对您有所帮助!
第一步:定义一个或多个颜色资源,如res/values/colors.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#3f51b5</color>
<color name="primary_dark">#1a237e</color>
<color name="accent">#ffee58</color>
</resources>
第 2 步:单击出现在资源编辑器边栏中资源左侧的色样:
单击该样本将弹出一个颜色选择器对话框:
第 3 步:单击该对话框中色样栏左侧的吸管工具。这将调出跟随鼠标指针的典型滴管视图。将鼠标悬停在要拾取的颜色上,然后单击鼠标左键。返回对话框,单击“选择”以更新颜色资源以使用选择的颜色。
第 4 步:在您的布局中,使用 @color/whatever_name_you_give_it
来引用颜色,其中 whatever_name_you_give_it
是您为其指定的任何名称。
有很多网站可以帮助您选择图像颜色。我个人使用 pickimagecolor.com,因为您甚至可以找到使工作更轻松的颜色阴影。它允许您从计算机上传图像,您可以轻松找到十六进制、RGB() 颜色和 HSV 颜色代码。我只是复制颜色代码并使用它。这是一个图像颜色选择器网站,但您也可以使用它来将颜色代码 Hex 转换为 RGB 、 RGB 到 HEX 以及更多可用选项。希望对你有帮助。