【问题标题】:Need to set Imageview same in all device in android using FancyCoverflow需要使用 FancyCoverflow 在 android 中的所有设备中设置相同的 Imageview
【发布时间】:2015-04-07 07:34:19
【问题描述】:

我正在研究精美的封面流。现在如下所示的代码

 public View getCoverFlowItem(int i, View reuseableView, ViewGroup viewGroup) {
    ImageView imageView = null;

  /*  Display display = viewGroup.getDisplay();
    Point size = new Point();
    display.getSize(size);
    int  width = size.x;
    int  height = size.y;*/

    if (reuseableView != null) {
        imageView = (ImageView) reuseableView;
    } else {
        imageView = new ImageView(viewGroup.getContext());
        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setLayoutParams(new FancyCoverFlow.LayoutParams(300,400));


    }

    imageView.setImageResource(this.getItem(i));
    return imageView;
}

正在传递的布局参数是静态整数。这显然将图像视图放在不同设备中的不同位置。有什么想法可以像 match parent 一样使用或以编程方式对其应用重力。

【问题讨论】:

    标签: android layout coverflow


    【解决方案1】:

    您可以设置布局参数以匹配父级

    imageView.setLayoutParams(new Gallery.LayoutParams(
        Gallery.LayoutParams.MATCH_PARENT,
        Gallery.LayoutParams.MATCH_PARENT));
    

    您也可以将它们设置为WRAP_CONTENT,并将正确大小的位图放置到您的drawable 文件夹中。这将确保图像在以dip 测量的所有屏幕上具有相同的尺寸。

    【讨论】:

    • 因为封面流使用了画廊类。它显示了 ViewGroup 布局参数之类的类转换异常不能转换为 Gallery 布局参数。
    • 然后将ViewGroup替换为Gallery
    • 它根本不工作。只是我想设置布局的高度和宽度,而我无法通过明显的方式(例如更改 layoutParams)来设置。
    猜你喜欢
    • 2016-07-06
    • 1970-01-01
    • 2015-02-19
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多