繁体   English   中英

当我运行我的应用程序时,不会显示图像,但是会显示文本等

[英]When I run my app the images are not displayed however the text etc is

以下是我使用Glide将imageurl转换为imageView的部分代码。

@Resolve
    private void onResolved() {
        titleTxt.setText(mInfo.getTitle());
        captionTxt.setText(mInfo.getCaption());
        timeTxt.setText(mInfo.getTime());
        Glide.with(mContext).load(mInfo.getImageUrl()).into(imageView);

以下是我正在使用的json文件

{
                "title": "Livery Hunting At The Festival Of Speed",
                "image_url": "http://speedhunters-wp-production.s3.amazonaws.com/wp-content/uploads/2017/07/14045435/goodwood-festivalofspeed-jordanbutters-speedhunters-1652-1200x801.jpg",
                "caption": "The Goodwood Festival of Speed boasts vehicular variety like few other annual gatherings.",
                "time": "13 hours ago"
            }

在下面,我添加了我要实现的XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="10dp"
    android:paddingRight="20dp"
    android:paddingTop="10dp"
    android:paddingBottom="20dp"
    android:gravity="left"
    android:background="@drawable/bottom_border_on_light">
    <android.support.v7.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        app:cardCornerRadius="4dp"
        app:cardElevation="1dp">
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="60dp"
            android:layout_height="80dp"
            android:layout_gravity="top"
            android:scaleType="centerCrop"/>
    </android.support.v7.widget.CardView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical">
        <TextView
            android:id="@+id/titleTxt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/white"
            android:textSize="16sp"
            android:typeface="sans"
            android:textStyle="normal"/>
        <TextView
            android:id="@+id/captionTxt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:textColor="@color/white"
            android:textSize="12sp"
            android:typeface="sans"
            android:textStyle="normal"/>
        <TextView
            android:id="@+id/timeTxt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_gravity="right"
            android:textColor="@color/white"
            android:textSize="12sp"
            android:typeface="sans"
            android:textStyle="normal"/>
    </LinearLayout>
</LinearLayout>

就调整大小而言,我必须在java类中调整其大小,还是使用XML布局文件调整其大小。

Glide.with(mContext).load(mInfo.getImageUrl()).override(100,‌​100).into(imageView)‌​;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM