【发布时间】:2019-07-15 07:47:44
【问题描述】:
Picasso 无法将图像drawable 加载到ImageView,我尝试更改ImageView 的宽度和高度、调整图像大小、加载或不加载fit()、resize() 或center() 并且图像仍然不可见。我在整个项目中使用Picasso,并且到处都可以正常工作,但是在这个项目中没有结果。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainFullFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/mainThemeBlack"
tools:context=".MainTabsActivity">
<RelativeLayout
android:id="@+id/rlSynchroView"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:background="@color/bottom_sheet_blue">
<TextView
android:id="@+id/tvSynchroLast"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:layout_marginEnd="10dp"
android:textColor="@color/mdtp_white"
android:text="Last synchro: 10:38"/>
<ImageView
android:id="@+id/ivSynchroIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvSynchroLast"
android:elevation="5dp"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/listFullView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:dividerHeight="10.0sp"
android:layout_above="@id/rlSynchroView"
android:background="?android:attr/selectableItemBackground"
android:divider="@color/mainThemeBlack"
android:paddingBottom="70dp"
android:clipToPadding="false">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
方法调用:
Picasso.get().load(R.drawable.refresh_icon)
.resize(10, 10)
.into(refreshIV);
我在 onViewCreated() 内部调用它,我也尝试用不同的值调整它的大小。
我想实现带有刷新图标的可点击底部栏(以及有关上次同步时间的信息),以与onClick方法内的服务同步数据
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.list_full, container, false);
refreshIV = mView.findViewById(R.id.ivSynchroIcon);
mobileArray = new ArrayList<IssuePOJO>();
dbStats.open();
generateList();
mView = view;
return mView;
}
【问题讨论】:
-
refreshIV在哪里? -
我已经编辑了我的问题,mView 对于这个 Fragment 是全局的,所以我可以在任何地方将它用于 findViewById()
标签: android android-layout picasso