Android中的QuiltView库

时间:2013-10-29 06:21:26

标签: android

我正在开发一个Android应用程序,我正在使用被子视图库我只是想知道如何更改图像块的大小并允许我的图像适合屏幕边缘,即删除所有边距 如果有任何身体可以帮助我

我的MainActivity代码是

public class MainActivity extends Activity {

    public QuiltView quiltView;

    public ImageView icon1, icon2, icon3, icon4, icon5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        quiltView = (QuiltView)findViewById(R.id.quilt);
        quiltView.setChildPadding(1);

        icon1 = new ImageView(this);
        icon1.setImageResource(R.drawable.agri);
        icon1.setScaleType(ScaleType.FIT_XY);


        icon2 = new ImageView(this);
        icon2.setImageResource(R.drawable.finanace);
        icon2.setScaleType(ScaleType.CENTER_CROP);

        icon3 = new ImageView(this);
        icon3.setImageResource(R.drawable.health);
        icon3.setScaleType(ScaleType.CENTER_CROP);


        icon4 = new ImageView(this);
        icon4.setImageResource(R.drawable.travel);
        icon4.setScaleType(ScaleType.CENTER_CROP);

        /*icon5 = new ImageView(this);
        icon5.setImageResource(R.drawable.agriculture);
        icon5.setScaleType(ScaleType.CENTER_INSIDE);*/

        ArrayList<ImageView> images = new ArrayList<ImageView>();
        images.add(icon1);
        images.add(icon2);
        images.add(icon3);
        images.add(icon4);
        //images.add(icon5);

        quiltView.addPatchImages(images);

    }

}

1 个答案:

答案 0 :(得分:0)

我建议您使用AQUery在QuiltView中设置图像

AQuery aq=new AQuery(this);
ImageView icon4 = new ImageView(this);
            aq.id(icon4).image(R.drawable.travelPic, true, true, 0, 0,
                    null, AQuery.FADE_IN, AQuery.RATIO_PRESERVE);
            icon4.setScaleType(ScaleType.CENTER_CROP);

如果你对AQuery不满意,你必须为QuiltView中的每个图像设置padding