0

Пытаюсь создать GridView но никак не могу изменить высоту элементов.

введите сюда описание изображения GridView Item.

<?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="match_parent"
android:layout_height="wrap_content"
android:background="#222222"
android:orientation="vertical"
android:padding="10dp">
<ImageView
    android:id="@+id/ProductImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitStart" />
<LinearLayout
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1"
    android:background="#55000000"
    android:paddingBottom="15dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">
    <TextView
        android:id="@+id/ProductNameTextView"
        android:textColor="@android:color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="20" />
    <ImageView
        android:src="@drawable/ic_drawer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/imageView1"
        android:layout_weight="80" />
</LinearLayout>

Home activty.

<?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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient">
<android.support.design.widget.FloatingActionButton
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:id="@+id/GoToCartPage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="20dp"
    android:layout_marginBottom="20dp"
    android:layout_gravity="bottom|end"
    app:srcCompat="@drawable/ic_cart" />
<LinearLayout
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout1">
    <android.support.v7.widget.SearchView
        android:minWidth="25px"
        android:minHeight="25px"
        android:id="@+id/searchView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
    android:layout_below="@id/linearLayout1"
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/linearLayout2">
    <GridView
        android:id="@+id/ProductListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="auto_fit"
        android:horizontalSpacing="10dp"
        android:verticalSpacing="10dp"
        android:gravity="center"
        android:clipToPadding="true"
        android:fitsSystemWindows="true"
        android:stretchMode="columnWidth" />
</LinearLayout>

1 ответ 1

0

Вы пробовали у картинке изменить размеры? Но прежде попробуйте установить ImageView android:scaleType="centerCrop" Если картинка после этого занята всё темное пространство, тогда измените атрибуты ImageView.

<ImageView
    android:id="@+id/ProductImageView"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:scaleType="fitStart" />

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.