- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Web 服务,我正在使用改造从中获取图像。我在 imageView 中显示这些图像并使用 recyclerview 加载多个图像。
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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/planscontainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/subscplans"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/backplans"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="50dp"
android:background="@drawable/leftarrow" />
<ImageView
android:id="@+id/appiconhere"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="400dp"
android:src="@drawable/moremovelogo" />
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/planname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="41dp"
android:layout_marginEnd="319dp"
android:text="Plan Id:"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subscplans" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="324dp"
android:layout_marginTop="41dp"
android:layout_marginBottom="28dp"
android:text="1"
app:layout_constraintBottom_toTopOf="@+id/textView11"
app:layout_constraintStart_toEndOf="@+id/planname"
app:layout_constraintTop_toBottomOf="@+id/subscplans"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="28dp"
android:text="Plan Name:"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/planname" />
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="20dp"
android:text="Price:"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/duration" />
<TextView
android:id="@+id/noofmoviesdownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="18dp"
android:layout_marginEnd="191dp"
android:text="No. of movies can be download:"
app:layout_constraintEnd_toStartOf="@+id/textView13"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/price" />
<TextView
android:id="@+id/canbeviewed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="213dp"
android:text="No. of movies can be viewed"
app:layout_constraintEnd_toStartOf="@+id/textView14"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/noofmoviesdownload" />
<TextView
android:id="@+id/samemovieviewed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="143dp"
android:text="No. of times same movie can be viewed"
app:layout_constraintEnd_toStartOf="@+id/textView15"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/canbeviewed" />
<TextView
android:id="@+id/timesdownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="17dp"
android:layout_marginEnd="126dp"
android:text="No. of times same movie can be download"
app:layout_constraintEnd_toStartOf="@+id/textView16"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/samemovieviewed" />
<TextView
android:id="@+id/rentpe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="26dp"
android:layout_marginTop="18dp"
android:layout_marginEnd="119dp"
android:text="No. of times same movie can be get on rent"
app:layout_constraintEnd_toStartOf="@+id/textView17"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/timesdownload" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="310dp"
android:layout_marginTop="28dp"
android:text="TextView"
app:layout_constraintStart_toEndOf="@+id/duration"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="362dp"
android:layout_marginTop="19dp"
android:text="TextView"
app:layout_constraintStart_toEndOf="@+id/price"
app:layout_constraintTop_toBottomOf="@+id/textView11" />
<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="194dp"
android:layout_marginTop="19dp"
android:text="TextView"
app:layout_constraintStart_toEndOf="@+id/noofmoviesdownload"
app:layout_constraintTop_toBottomOf="@+id/textView13" />
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="216dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="480dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/canbeviewed"
app:layout_constraintTop_toBottomOf="@+id/textView14" />
<TextView
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="146dp"
android:layout_marginTop="25dp"
android:text="TextView"
app:layout_constraintStart_toEndOf="@+id/samemovieviewed"
app:layout_constraintTop_toBottomOf="@+id/textView15" />
<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="130dp"
android:layout_marginTop="16dp"
android:text="TextView"
app:layout_constraintStart_toEndOf="@+id/timesdownload"
app:layout_constraintTop_toBottomOf="@+id/textView16" />
<Button
android:id="@+id/buyplan"
android:layout_width="194dp"
android:layout_height="wrap_content"
android:layout_marginStart="227dp"
android:layout_marginTop="106dp"
android:layout_marginEnd="59dp"
android:background="@color/tw__composer_blue"
android:text="Buy Plan"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView13"
app:layout_constraintTop_toBottomOf="@+id/subscplans" />
<Button
android:id="@+id/showplans"
android:layout_width="194dp"
android:layout_height="wrap_content"
android:layout_marginStart="224dp"
android:layout_marginTop="37dp"
android:layout_marginEnd="62dp"
android:layout_marginBottom="229dp"
android:background="#d156b8"
android:text="Show plans"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView15"
app:layout_constraintTop_toBottomOf="@+id/buyplan"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="121dp"
android:layout_marginTop="19dp"
android:text="TextView"
app:layout_constraintStart_toEndOf="@+id/rentpe"
app:layout_constraintTop_toBottomOf="@+id/textView17" />
<RelativeLayout
android:id="@+id/linearlayoutimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView19">
<android.support.v7.widget.RecyclerView
android:id="@+id/myrecyclerview"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
<Button
android:id="@+id/cancelplan"
android:layout_width="194dp"
android:layout_height="wrap_content"
android:layout_marginStart="221dp"
android:layout_marginTop="37dp"
android:layout_marginEnd="60dp"
android:background="@color/tw__composer_deep_gray"
android:text="cancel plan"
android:textColor="@color/white"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView17"
app:layout_constraintTop_toBottomOf="@+id/showplans" />
</android.support.constraint.ConstraintLayout>
对于我拥有的元素:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/imagethumb"
android:layout_width="180dp"
android:layout_height="200dp"
android:scaleType="fitEnd"/>
<TextView
android:id="@+id/nothing"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我的 Adapter 类如下所示:这是我的适配器类名 ImageAdapter.java
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.SubsImageHolder> {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.newlogo)
.showImageForEmptyUri(R.drawable.newlogo)
.showImageOnFail(R.drawable.newlogo)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
private Context context;
private List<ThumbPojo> imageList;
public ImageAdapter(Context context, List<ThumbPojo> items) {
this.context = context;
this.imageList = items;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public List<ThumbPojo> getImageList() {
return imageList;
}
public void setImageList(List<ThumbPojo> imageList) {
this.imageList = imageList;
}
@NonNull
@Override
public SubsImageHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater.inflate(R.layout.subscriptionimages, viewGroup, false);
return new SubsImageHolder(view);
}
@Override
public void onBindViewHolder(@NonNull SubsImageHolder subsImageHolder, int i) {
ThumbPojo item = imageList.get(i);
subsImageHolder.textView.setText(item.getMovieName());
subsImageHolder.imageView.setImageDrawable(null);
subsImageHolder.imageView.layout(0,0,0,0);
ImageLoader.getInstance().displayImage(item.getThumbnail(),subsImageHolder.imageView,options);
// Glide.with(context)
// .load(item.getThumbnail())
// .into(subsImageHolder.imageView);
}
@Override
public int getItemCount() {
return imageList.size();
}
class SubsImageHolder extends RecyclerView.ViewHolder {
ImageView imageView;
TextView textView;
public SubsImageHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imagethumb);
textView = itemView.findViewById(R.id.nothing);
}
}
}
我设置适配器的主要 Activity 是:SubscriptionPlans.java:
public class SubscriptionPlans extends AppCompatActivity {
TextView planid, planname, planprice, noofmoviedownload, noofmovieviewed, sameviewed, samedownload, rentit, nomovi;
Intent intent = getIntent();
ImageView imageView3, imageView4;
String one, two, three, four, five, six, seven, eight;
List<ThumbPojo> list;
Button button;
Button show, buy, cancel;
int position;
String allvalues;
RelativeLayout linearLayout;
String id;
int userid, usertype;
int po;
String ress;
public String subs;
List<CheckActiveOrNot> list1;
RecyclerView recyclerView;
ImageAdapter imageAdapter;
List<ThumbPojo> imageList;
List<String> images = new ArrayList<>();
AVLoadingIndicatorView progressBar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.premiumsubscriptionplans);
// progressBar=findViewById(R.id.progressBar);
// showProgressDialog();
* recyclerView = findViewById(R.id.myrecyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false));*
userid = SharedPrefsHelper.getUserId(SharedPrefsHelper.USER_ID, 0);
usertype = SharedPrefsHelper.getUserType(SharedPrefsHelper.USER_TYPE, 0);
linearLayout = findViewById(R.id.linearlayoutimage);
// imageView4 = findViewById(R.id.imageView4);
planid = findViewById(R.id.textView3);
planname = findViewById(R.id.textView11);
planprice = findViewById(R.id.textView13);
noofmoviedownload = findViewById(R.id.textView14);
noofmovieviewed = findViewById(R.id.textView15);
sameviewed = findViewById(R.id.textView16);
samedownload = findViewById(R.id.textView17);
rentit = findViewById(R.id.textView19);
TextView notshow = findViewById(R.id.planname);
notshow.setVisibility(View.GONE);
planid.setVisibility(View.GONE);
button = findViewById(R.id.backplans);
show = findViewById(R.id.showplans);
buy = findViewById(R.id.buyplan);
cancel = findViewById(R.id.cancelplan);
id = getIntent().getStringExtra("planid");
imageList = new ArrayList<>();
Call<List<ThumbPojo>> caller = ApiClient.getInstance().getApiService().getThumbimages(id);
caller.enqueue(new Callback<List<ThumbPojo>>() {
@Override
public void onResponse(Call<List<ThumbPojo>> call, Response<List<ThumbPojo>> response) {
list =response.body();
// JSONArray jsonArray=new JSONArray(list);
// for(int i=0;i<jsonArray.length();i++)
// {
// try {
// JSONObject jsonObject=jsonArray.getJSONObject(i);
// String name=jsonObject.getString("movieName");
// String imageurl=jsonObject.getString("thumbnail");
//
// ThumbPojo thumbPojo=new ThumbPojo(name,imageurl);
// imageList.add(thumbPojo);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// }
*imageAdapter=new ImageAdapter(SubscriptionPlans.this,list);
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(imageAdapter);
// dismissProgressDialog();*
// if (list.get(position).getThumbnail() != null) {
// ImageLoader.getInstance().displayImage(list.get(position).getThumbnail(), imageView3, options);
// // ImageLoader.getInstance().displayImage(list.get(position).getThumbnail(),imageView4,options);
// } else {
// nomovi.setText("No movies under this plan");
// }
}
@Override
public void onFailure(Call<List<ThumbPojo>> call, Throwable t) {
t.getMessage();
}
});
出于图像加载的目的,我使用了通用图像加载器。现在问题来了,当单个图像来自服务器时,它会根据 imageview 中提到的宽度和高度加载。但是当有两个或更多图像出现时,图像的大小是不同的。
我已经尝试了几乎所有来自互联网的解决方案,但没有任何效果。我还将布局设置为 (0,0,0,0),但这也无法解决此问题。
图像看起来像这样我不知道为什么?
最佳答案
将项目中ImageView
的scaleType
更改为center_crop
,这将使图像定义大小(dp
s) 并将裁掉剩余部分,使所有图像大小相同。
像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imagethumb"
android:layout_width="180dp"
android:layout_height="200dp"
android:scaleType="center_crop"/>
<TextView
android:id="@+id/nothing"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
关于android - 如何在不影响 imageview 中定义的大小的情况下在 recyclerview 中加载图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54229602/
我正在尝试创建一个演示应用程序,我想在其中创建一个 ImageView ,该 ImageView 相互重叠,x 和 y 坐标略有变化(类似于所有纸牌相互重叠的任何纸牌游戏,但我们可以看到数字)。如果用
您好,我有一个要求,我需要通过拖动 ImageView 的右角来调整 ImageView 的大小和旋转 ImageView 。 我可以通过拖动 ImageView 的角成功地调整 ImageView
我目前正在尝试使用 JavaFX 在 ImageView 中居中图像。 所以我在 View 中加载图像: Image img = new Image("..."); imageView.setImag
我有一个非常简单的问题要问:我需要在屏幕右下角的 ImageView 上放一个小 Logo ,整个屏幕都很大,但我不知道如何设置坐标或如何设置说 ImageViews 处于相对位置。 像这样: 最佳答
我想像这样制作一个 ImageView 覆盖另一个 ImageView;只有一半的绿色圆圈覆盖了图像: 我试过使用 RelativeLayout 并将两个 ImageView 都放在里面。然后我使用
我们如何使 ImageView 的宽度和高度等于父 ConstraintLayout 的宽度?所以它显示一个全宽的方形 ImageView。 通常如何设置某个小部件的高度等于其他小部件的宽度? 最佳答
有点像刽子手 如果 ImageView 中有东西,如何跳过 ImageView 并检查其中是否有东西尝试检查 imageView 中是否有图像 代码 final boolean imageT
我正在用 swift 制作一种“保持在线条之间”iPhone 应用程序,我有一个移动 ImageView 和 2 个代表线条的 ImageView 。如何检测移动 ImageView 何时撞击或接触线
我正在做一个应用程序,用户通过单击图像(ImageView1)可以在另一个ImageView2中看到它。所以我尝试在变量中获取 ImageView1 的图像 BufferedImage img= Sw
我有以下看法: 如果我点击任何 ImageButton 以全屏模式显示相应的图像。例如,如果我点击 Black ,它会显示 ImageView ,如: 我还为一些图像按钮将背景设置为全屏颜色:如果我单
我在名为 DialButton2 的类中扩展了 ImageView 类(不要担心类的名称,它无关紧要)。 DialButton2 类所做的只是显示位于可绘制文件夹中的任 Intent 像。 packa
我正在使用 Xcode 8.1 和 swift 3.0 开发应用。 使用 Storyboard ,我扩展了一个 ImageView 以占据整个 View ,并为其设置了一张图片以用作背景图像(使用 s
如何将我的 imageView 裁剪成我在项目中有图像的气泡形状。 最佳答案 以下是调整大小或裁剪图像的简单代码,您只需根据需要为图像传递高度或宽度即可: 获取裁剪图像: UIImage *cropp
我有 92 张图像,我希望有一个指示符(例如复选标记)来指示图像已解锁。我在 .png 文件中有复选标记,我首先尝试的是为每个图像制作单独的副本,并将复选标记放在 Photoshop 中的图像顶部。但
我有两个 ImageView ,它们看起来像这样。我想将 TouchListener 添加到 imageview1。但听众无法正常工作。我正在将 imageview2 添加到 android:foc
我有一个列表布局,其中包含如下所示的项目: 首先有一个 ImageView(灯光),然后是两个 textView。所有这些都在 TableLayout 中。 (来源:http://code.googl
我想知道如何将 ImageView 元素添加到 JavaFx 2.1 中的区域元素。 也许我把这个元素的用法弄错了,但 AFAIK 它也是子元素的容器。 背景是我需要一个定义大小的区域,该区域应显示独
我在调整 StackPane 中的 ImageView 大小时遇到了问题:如果 StackPane 是根容器并且我将图像的高度和宽度绑定(bind)到 StackPane,那么一切都很好。
** 我有两个 ImageView ,一个用于背景,一个用于前景,我正在前景 ImageView 上绘图。对于删除功能,我这样做是因为我不想在删除时删除背景图像。它正在执行很好。现在我想保存该图像(背
我正在尝试为 watch 应用程序创建 ImageView ,我正在尝试以编程方式创建,但经典 View Controller 中使用的代码不起作用。 let imageName = "yourIma
我是一名优秀的程序员,十分优秀!