这个是point_normal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="5dp"/>
<solid android:color="@android:color/darker_gray"/>
</shape>
下面这段代码使用上面的xml 但在程序中却显示不出来
ImageView iv ;
View view ;
LayoutParams layoutParams;
for (int i = 0; i < imageIds.length; i++) {
iv = new ImageView(this);
iv.setBackgroundResource(imageIds[i]);
imageViewsList.add(iv);
view = new View(this);
view.setBackgroundResource(R.drawable.point_normal);
layoutParams = new LayoutParams(20,20);
if(i!=0)
{
layoutParams.leftMargin=30;
}
view.setLayoutParams(layoutParams);
llPointGroup.addView(view);
}
------解决思路----------------------
试试 setBackgroundDrawable?
------解决思路----------------------
setBackground(getResources().getDrawable(R.drawable.point_normal))