use*_*118 5 android imageview android-volley networkimageview scaletype
我正在尝试使用 ViewPager 和 Volley 的 NetworkImageView 制作图像库。viewpager 和图像检索一切正常。但是当我将位图放入 NetworkImageView 中时,图像不会拉伸以填充 NetworkImageView 的大小。对于我的其他 ImageView,设置scaleType 效果很好。
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
Run Code Online (Sandbox Code Playgroud)
我的 xml 文件
public static class SwipeFragment extends Fragment {
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
NetworkImageView imageView = (NetworkImageView) swipeView.findViewById(R.id.imageView);
Bundle bundle = getArguments();
int position = bundle.getInt("position");
if (imageLoader == null) {
imageLoader = AppController.getInstance().getImageLoader();
}
imageView.setImageUrl(fotoUrl.get(position), imageLoader);
return swipeView;
}
static SwipeFragment newInstance(int position) {
SwipeFragment swipeFragment = new SwipeFragment();
Bundle bundle = new Bundle();
bundle.putInt("position", position);
swipeFragment.setArguments(bundle);
return swipeFragment;
}
}
Run Code Online (Sandbox Code Playgroud)
我的爪哇
对这个问题有什么想法吗?我也尝试将scaleType更改为fitCenter,但结果仍然相同。先感谢您。
我认为你的问题是因为用于宽度和高度的wrap_content值。尝试使用下面的代码,它应该可以工作。
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="fitXY" />
Run Code Online (Sandbox Code Playgroud)
当您说wrap_content时,这意味着您要求视图与图像具有相同的高度和宽度,因此缩放不适用。固定宽度和高度后,您可以应用 fitXY 比例类型。
| 归档时间: |
|
| 查看次数: |
5263 次 |
| 最近记录: |