<pre class="java" name="code">//创建图形
private void initimage() {
mLayout = (LinearLayout) mView.findViewById(R.id.ll);
mImageViews = new ArrayList<ImageView>();
mImageViews.clear();
mLayout.removeAllViews();
for (int i = 0; i < mData.size(); i++) {
ImageView imageView = new ImageView(getActivity());
if (i == 0) {
imageView.setImageResource(R.drawable.xuanzhong);
} else {
imageView.setImageResource(R.drawable.weixuanzhong);
}
mImageViews.add(imageView);
//设置大小
LayoutParams index = new LayoutParams(10, 10);
//间距
index.setMargins(10, 0, 10, 0);
mLayout.addView(imageView, index);
}
}
//未选中
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<corners android:radius="10dp"/>
<solid android:color="#CDCDCD"/>
</shape>
//选中
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<corners android:radius="10dp"/>
<solid android:color="#D90000"/>
</shape>