@cepprice

Как ограничить высоту ListView?

Как сделать так, чтобы ListView имел layout_height=h1 (см. Скриншот).5c5716ac5e90a745915997.png
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".AlarmsActivity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@color/colorPrimaryDark"
        android:text="@string/app_name"
        android:textColor="@color/colorAccent"
        android:textAllCaps="true"
        android:padding="10dp"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="100dp">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/background_orange"
            android:scaleType="centerCrop"/>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon"/>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="35dp"
        android:orientation="horizontal"
        android:background="@color/colorPrimary"
        android:padding="8dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="@string/add_new_alarm"
            android:textColor="@color/colorAccent"
            android:textAllCaps="true"
            android:textSize="12sp"/>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_add_circle_outline_black_24dp"
            android:layout_alignParentRight="true"/>
    </RelativeLayout>

    <include layout="@layout/view_dividing_line"/>



    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorPrimary">

        <ListView
            android:id="@+id/list_view_alarms"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <include layout="@layout/view_dividing_line"
            android:id="@+id/bottom_dividing_line"
            android:layout_width="match_parent"
            android:layout_height="10dp"
            android:layout_below="@id/list_view_alarms"/>

        <View
            android:layout_height="40dp"
            android:layout_width="match_parent"
            android:background="@color/colorPrimary"
            android:layout_alignParentBottom="true" />

    </RelativeLayout>

</LinearLayout>
  • Вопрос задан
  • 273 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Tiberal
RecyclerView может layout_height = "wrap_content", ListView не может(считать руками).
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы