【问题标题】:Is there a way to pick a certain colour from another image source and use it without a 3rd party program?有没有办法从另一个图像源中选择某种颜色并在没有第三方程序的情况下使用它?
【发布时间】:2017-07-04 23:05:40
【问题描述】:

我在 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>

【问题讨论】:

    标签: android android-studio android-xml


    【解决方案1】:

    步骤#1:定义一种或多种颜色资源,例如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 是您给它的任何名称。

    【讨论】:

      【解决方案2】:

      如果您的意思是要使用吸管工具来测量十六进制值(例如 #ff0000)或 RGB 值(例如 rgb(255, 0, 0) em>) 的特定像素,有许多网站允许您执行此操作。

      例如,如果您在网络上搜索“online color picker from image,就会出现许多好网站。我使用 Google 上出现的第一个,Image Color Picker(您可以找到自己的),它可以让您选择图片来自网络的 URL上传图片来自您的计算机。

      希望这会有所帮助!

      【讨论】:

        【解决方案3】:

        有许多网站可帮助您选择图像颜色。我个人使用pickimagecolor.com,因为您甚至可以找到使工作更轻松的色调。它允许您从计算机上传图像,您可以轻松找到十六进制、RGB() 颜色和 HSV 颜色代码。我只是复制颜色代码并使用它。它是一个图像颜色选择器网站,但您也可以使用它来将颜色代码 Hex 转换为 RGB,RGB 转换为 HEX,还有更多可用选项。希望对您有所帮助。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2021-10-27
          • 2019-10-14
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-04-07
          • 2023-03-10
          相关资源
          最近更新 更多