我希望你运行这行代码
ShaderImageView imageview = new ShapeImageView(getBaseContext(), null, R.style.hexagonstyle);
newphoto.setImageResource(R.drawable.image08);
layout.addView(newphoto);
并收到此错误:
Caused by: java.lang.RuntimeException: No resource is defined as shape
hexagone 定义为
<style name="hexagonstyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="siBorderColor">@color/hexagoninnerborder</item>
<item name="siBorderWidth">1dp</item>
<item name="siShape">@raw/maskcopya</item>
</style>
依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.github.siyamed:android-shape-imageview:0.9.2@aar'
}
有关ShapeImageView的更多信息:https://github.com/siyamed/android-shape-imageview
如何以编程方式添加 ShapeImageView ?也许 ShapeImageView()的参数错误......
提前致谢!
答案 0 :(得分:0)
反过来说:
View view = LayoutInflater.from(this).inflate(R.layout.contactlist, null);
ImageView contactimage = (ImageView) view.findViewById(R.id.contactimage);
我将 ShaderImageView 放入 contactlist.xml 并在那里设置样式
解决了:)