根据值更改符号的颜色

时间:2018-05-23 07:25:15

标签: android listview imageview

在我的Android应用程序中,我得到了一个基于ListView的菜单,代码如下所示:

  <RelativeLayout>
    <ListView
    android:id="@+id/androidList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
    </RelativeLayout>


    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="8dp">

    <ImageView
        android:id="@+id/symbol"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:src="@drawable/symbol1" />

    <TextView
        android:id="@+id/aNametxt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="12dp"
        android:layout_marginStart="12dp"
        android:layout_marginTop="8dp"
        android:layout_toEndOf="@+id/appIconIV"
        android:layout_toRightOf="@+id/appIconIV"
        android:maxLines="1"
        android:text="Android Name"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/aVersiontxt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/aNametxt"
        android:layout_alignStart="@+id/aNametxt"
        android:layout_below="@+id/aNametxt"
        android:maxLines="1"
        android:text="Android Version"
        android:textSize="14sp" />
</RelativeLayout>

我希望此应用为用户在应用内可以达到的特定级别设置特定主题(级别基于分数)。假设我们得到了1级,2级......现在我可以设计5个不同的符号,每个符号都有一个特定的 color 并设置特定的 icon 对于特定级别 - 但是当我想到5 x 10图标+背景的数据量时......我问自己:有没有办法让它更轻盈?< / EM> 或者我应该在服务器端使用图标并直接从我的服务器加载它们?它应该尽可能安全,以防止用户伪造显示的表面。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

你可以做两种方式,但如果在我的脑海中保持轻量级,最好的选择是服务器端。直接从服务器加载它们。

您可以使用名为Glide的库,它是一个轻量级图像加载库,并且还具有转换功能。