У меня есть выбор миниатюр.При выделении миниатюра заменяет main_image.
Мой макет:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/lightGray"
tools:context=".ExpandedProduct">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
<LinearLayout
android:id="@+id/product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/main_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/thumbnails"
android:layout_marginBottom="10sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
(каждый эскиз загружается в утилизацию). Проблема: Когда я нажимаю на миниатюру,оно становится основным изображением, но оно очень маленькое - меньше миниатюры. (я пытался обернуть main_image в макете ограничений - без изменений.)
Чтобы отреагировать на нажатие,реализован интерфейс, в котором установлен адаптер.Вот код onClick, где миниатюра становится основным изображением в моем фрагментном скрипте:
all_image.setAdapter(new ProductImagesAdapter(getProductImages(), new ProductImagesAdapter.OnItemSelectedListener()
{
@Override
public void onItemClick(String url)
{
ImageRequest manRequest = new ImageRequest(url, new Response.Listener<Bitmap>()
{
@Override
public void onResponse(Bitmap response)
{
main_image.setImageBitmap(response);
}
}, 0, 0, ImageView.ScaleType.CENTER_CROP, Bitmap.Config.RGB_565, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Log.d("Image Request", error.toString());
}
});
NetworkVolleySingleton.getInstance(getContext()).addToRequestQueue(manRequest);
}
}));
Как вы можете видеть, я загружаю изображение с его URL, используя Volley .
Как получить выбранное эскизное изображение для заполнения "рамки" main_image?