我使用毕加索来加载我的可绘制图像,因为它们具有高分辨率。
现在的问题是:并非所有图像都在加载,有时活动中显示3个4图像,有时4个图像中有1个。
以下是代码:
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.Picasso;
public class SummaryOfTour extends AppCompatActivity {
Context context;
ImageView imageView ,imageView1,imageView2,imageView3,imageView4,imageView5;
static int ms1,ms2,ms3,ms4,ms5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_summary_of_tour);
imageView = (ImageView) findViewById(R.id.img1);
imageView1 = (ImageView) findViewById(R.id.img2);
imageView2 = (ImageView) findViewById(R.id.img3);
imageView3 = (ImageView) findViewById(R.id.img4);
imageView4 = (ImageView) findViewById(R.id.img5);
if(ms1 ==1) {
Picasso.with(this)
.load(R.drawable.mp1)
.resize(1000, 1690)
.into(imageView);
Picasso.with(this)
.load(R.drawable.mp2)
.resize(1000, 1690)
.into(imageView1);
Picasso.with(this)
.load(R.drawable.mp3)
.resize(1000, 1690)
.into(imageView2);
Picasso.with(this)
.load(R.drawable.mp4)
.resize(1000, 1690)
.into(imageView3);
Picasso.with(this)
.load(R.drawable.bg)
.resize(1000, 1700)
.into(imageView4);
}
else if (ms2 ==1) {
Picasso.with(this)
.load(R.drawable.mp11)
.resize(1000, 1690)
.into(imageView);
Picasso.with(this)
.load(R.drawable.mp22)
.resize(1000, 1690)
.into(imageView1);
Picasso.with(this)
.load(R.drawable.mp33)
.resize(1000, 1690)
.into(imageView2);
Picasso.with(this)
.load(R.drawable.mp44)
.resize(1000, 1690)
.into(imageView3);
Picasso.with(this)
.load(R.drawable.bg)
.resize(1000, 1700)
.into(imageView4);
}
else if (ms3 ==1) {
Picasso.with(this)
.load(R.drawable.mp111)
.resize(1000, 1690)
.into(imageView);
Picasso.with(this)
.load(R.drawable.mp222)
.resize(1000, 1690)
.into(imageView1);
Picasso.with(this)
.load(R.drawable.mp333)
.resize(1000, 1690)
.into(imageView2);
Picasso.with(this)
.load(R.drawable.mp444)
.resize(1000, 1690)
.into(imageView3);
Picasso.with(this)
.load(R.drawable.bg)
.resize(1000, 1700)
.into(imageView4);
}
else if (ms4 ==1) {
Picasso.with(this)
.load(R.drawable.mp1111)
.resize(1000, 1690)
.into(imageView);
Picasso.with(this)
.load(R.drawable.mp2222)
.resize(1000, 1690)
.into(imageView1);
Picasso.with(this)
.load(R.drawable.mp5555)
.resize(1000, 1690)
.into(imageView2);
Picasso.with(this)
.load(R.drawable.mp7777)
.resize(1000, 1690)
.into(imageView3);
Picasso.with(this)
.load(R.drawable.mp66666)
.resize(1000, 1700)
.into(imageView4);
}
}
}
这是我的XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sumo.traffic.InfoOfArtInIsland"
android:background="#87E886"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="500dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/imageView5"
android:src="@drawable/loaders"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="100dp"
android:layout_gravity="right" />
</LinearLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="550dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img1"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/bckgrndViewFlipper1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="550dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img2"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/bckgrndViewFlipper1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="550dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img3"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/bckgrndViewFlipper1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="550dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img4"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/bckgrndViewFlipper1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="550dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img5"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/bckgrndViewFlipper1" />
</RelativeLayout>
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
</LinearLayout>
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- to be commented xml block goes here -->
<!-- <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="100dp"
android:id="@+id/imageButton3"
android:background="@drawable/faqz"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
</LinearLayout>
-->
</ScrollView>
</LinearLayout>
答案 0 :(得分:0)
在xml文件中定义图像源.... 机器人:SRC = “@ drawablw / yourimgname”
您的图片扩展名必须为“.png” 不得以和Integer ..
启动图像名称答案 1 :(得分:0)
Picasso.with(this)
.placeholder(R.drawable.mp1)
.resize(1000, 1690)
.into(imageView);
使用.placeholder加载。