就是平时新闻或者广告的定时滑动,广告底边不是有一条半透明的带和可以跟随滑动的几个圆点,我用LayoutParams写的布局,结果出来效果 圆点全叠在一起了,那半透明的带也在顶部去了,我想知道怎么才能把圆点分开且半透明的带也在底部?谢谢了!
public class FragmentDemo extends Fragment {
private ImageView mImageIds[];
private int index=0;//记录选中的图片位置
private static final int IMAGE_COUNT=3;//小圆点个数
Gallerys_Advertisement gallery;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
//整个Tabs之下的容器
LayoutParams SclayoutParams=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.MATCH_PARENT);
ScrollView scrollView=new ScrollView(getActivity());
scrollView.setLayoutParams(SclayoutParams);
//界面布局容器一
RelativeLayout R2Layout=new RelativeLayout(getActivity());
LayoutParams R2params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
R2Layout.setLayoutParams(R2params);
//画廊
LayoutParams galleryParams=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
gallery=new Gallerys_Advertisement(getActivity());
gallery.setFadingEdgeLength(0);//消除图片两边的阴影
gallery.setSpacing(0);
gallery.setLayoutParams(galleryParams);
//界面布局容器二
RelativeLayout relativeLayout=new RelativeLayout(getActivity());
//原来Layoutparams设置布局要使用Margins必须要加容器类型在Params语句前如下:RelativeLayout。
RelativeLayout.LayoutParams RRparams=new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,50);
// RRparams.setMargins(0, 0, 0, 0);
relativeLayout.setBackgroundColor(getResources().getColor(R.drawable.beijingse));//设置自定义背景色
relativeLayout.setLayoutParams(RRparams);
relativeLayout.setGravity(Gravity.CENTER);//确定圆点位置居中
//三张图
LayoutParams IVparams1=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ImageView imageView1=new ImageView(getActivity());
imageView1.setImageDrawable(getResources().getDrawable(R.drawable.ic_dot_focused));//重点:添加自定义图片
imageView1.setLayoutParams(IVparams1);
LayoutParams IVparams2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ImageView imageView2=new ImageView(getActivity());
imageView2.setImageDrawable(getResources().getDrawable(R.drawable.ic_dot_normal));//重点:添加自定义图片
imageView2.setLayoutParams(IVparams2);
LayoutParams IVparams3=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ImageView imageView3=new ImageView(getActivity());
imageView3.setImageDrawable(getResources().getDrawable(R.drawable.ic_dot_normal));//重点:添加自定义图片
imageView3.setLayoutParams(IVparams3);
relativeLayout.addView(imageView1);
relativeLayout.addView(imageView2);
relativeLayout.addView(imageView3);
R2Layout.addView(gallery);
R2Layout.addView(relativeLayout);
scrollView.addView(R2Layout);
mImageIds=new ImageView[]{imageView1,imageView2,imageView3};
mImageIds[0].setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_dot_focused));
ImgAdapter Gadapter=new ImgAdapter(getActivity());
gallery.setAdapter(Gadapter);
// Timer timer=new Timer();
// timer.schedule(task, 2000,2000);
// gallery.setOnItemSelectedListener(onItemSelectedListener);
return scrollView;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。