【发布时间】:2013-12-16 19:51:22
【问题描述】:
在我的 Android 应用程序中,我在背景中使用了一张图片,还使用了一些箭头图片。我在 xml 中添加了图像,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/backgroundimage" >
<LinearLayout
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.20"
android:background="@drawable/border"
android:gravity="center_horizontal"
android:weightSum="1" >
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/none"
android:gravity="right"
android:src="@drawable/navigation" />
</LinearLayout>
现在我想用一些提供的颜色代码更改 Java 代码中的图像颜色。图像背景将接收一种颜色,纹理/阴影/实际图像部分将接收另一种颜色。我听说了一些关于获取图像的 alpha 并在图像上应用颜色检查哪里是白色和哪里是灰色的。不知道该怎么做。
例如,我添加了箭头的图像。我想将背景从白色更改为不同的颜色,并将箭头更改为另一种颜色。请提出建议。
另外,如果图像处于背景透明的 alpha 模式,是否有任何方法可以更改颜色?
【问题讨论】: