Add*_*dev 6 java android android-glide
我正在测试滑动以在我的项目中加载图像.
我创建了以下布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageview"
android:background="#550000ff"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当我加载图像时,imageView.setImageResource(int)它正确加载(见下面的截图)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView= (ImageView) findViewById(R.id.imageview);
imageView.setImageResource(R.drawable.pen_logo);
}
Run Code Online (Sandbox Code Playgroud)
但是当我用滑动加载它时,图像会被扩展而忽略了wrap_content布局参数:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = (ImageView) findViewById(R.id.imageview);
Glide.with(this).load(R.drawable.pen_logo).into(imageView);
}
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
| 归档时间: |
|
| 查看次数: |
1293 次 |
| 最近记录: |