我是Android新手,我有一个像这样的合并视图:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="25dp"
android:layout_marginTop="8.33dp"
android:background="@drawable/text_border_top"
android:gravity="center"
android:includeFontPadding="true"
android:text="0 Points"
android:textColor="@color/GreenDark"
android:textSize="15sp" />
<!--android:layout_height="25dp"-->
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView"
android:layout_marginRight="25dp"
android:background="@drawable/text_border_bottom"
android:gravity="center"
android:includeFontPadding="true"
android:text="New Parent !"
android:textColor="#FFFFFF"
android:textSize="9sp" />
<!--android:layout_height="16.67dp"-->
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/lvl1" />
这是我的事:
<declare-styleable name="GamificationTagView">
<attr name="gamePoint" format="string" />
<attr name="levelTitle" format="string" />
<attr name="levelLogo" format="integer" />
<attr name="android:textColor" />
<attr name="levelTitleVisible" format="boolean" />
</declare-styleable>
这些是它的三个方法(GamificationTagView.java):
public void setGamePointText(String gamePoint) {
SpannableString ss1 = new SpannableString(gamePoint + " Points");
ss1.setSpan(new RelativeSizeSpan(1.5f), 0, ss1.length() - 6, 0); // twice the size of gamePoint
mGamePoint.setText(ss1);
}
public void setLevelTitleText(String levelTitle) {
mLvlTitle.setText(levelTitle);
}
public void setIconDrawable(String url) {
mIcon.setImageURI(Uri.parse(url));
}
使用调用这些方法的相同方法,我可以像往常一样设置文本,但我不知道mIcon.setImageURI
为什么不能正常工作。此网址链接没有问题,但它属于bad bitmap uri
和FileNotFoundException
:
E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: /https:/xxx/yyy.png: open failed: ENOENT (No such file or directory) 09-17 00:20:06.403 7175-7175/com.qqq.rrr I/System.out﹕ resolveUri failed on bad bitmap uri: https://xxx/yyy.png
这是我期望得到的:
但这就是我得到的:
我想知道为什么setImageUri不能用于我的复合视图以及如何解决它。请提前帮助和感谢。