Как растянуть ExpandableListView на весь экран?

Всем привет хочу у Вас спросить как можно растянуть 7-мь ExpandableListView элементов на весь экран. Задавать вручную размер каждого элемента не получаеться на других телефонах размер уходит. картинка

активити activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ExpandableListView
        android:id="@+id/expListView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ExpandableListView>

</LinearLayout>

Адаптер для ExpandableListView

package com.example.expenbllistview;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;

import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class MyExpandebleListAdapter extends BaseExpandableListAdapter {
final String TAG = "qwerty";
    private ArrayList<ArrayList<String>> mGroups;
    private Context mContext;
    String[] numer = {"1","2","3","4","5","6","7"};

    public MyExpandebleListAdapter (Context context,ArrayList<ArrayList<String>> groups){
        mContext = context;
        mGroups = groups;
    }

    @Override
    public int getGroupCount() {
        return mGroups.size();
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return mGroups.get(groupPosition).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return mGroups.get(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return mGroups.get(groupPosition).get(childPosition);
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
                             ViewGroup parent) {

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.custom_diary, null);
        }
        if (isExpanded){
            //Изменяем что-нибудь, если текущая Group раскрыта
        }
        else{
            //Изменяем что-нибудь, если текущая Group скрыта
        }
        ImageView plus = convertView.findViewById(R.id.plus);
        TextView num = convertView.findViewById(R.id.num);
        for(int i = 0; i < numer.length; i++){
            num.setText(numer[groupPosition]);
        }

        plus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG,groupPosition+"");
            }
        });

        return convertView;

    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                             View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.lst_view_castom, null);
        }

        CheckBox completeTarget = convertView.findViewById(R.id.completeTarget);
        completeTarget.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                Log.d(TAG,""+groupPosition + childPosition );
            }
        });

        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
}

Сам элемент

<?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">

    <LinearLayout
        android:id="@+id/lin"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:background="@drawable/vrec"
        tools:ignore="MissingConstraints">

        <LinearLayout
            android:id="@+id/linear"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@color/linnn"
            android:orientation="vertical">

            <TextView
                android:id="@+id/day"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/play"
                android:text="pn"
                android:textColor="@color/white"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/num"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:fontFamily="@font/play"
                android:gravity="center"
                android:text="1"
                android:textColor="@color/white"
                android:textSize="18sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/month"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/play"
                android:text="month"
                android:textColor="@color/white"
                android:textSize="12sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/spisok"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="24sp"
                android:layout_marginTop="10dp"
                android:fontFamily="@font/play"
                android:text="Spisok del:"
                android:textColor="@color/black"
                android:textSize="14sp" />


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="80dp"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/dop"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="24dp"
                    android:layout_marginTop="10dp"
                    android:fontFamily="@font/play"
                    android:text="2"
                    android:textColor="@color/black"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/slash"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:fontFamily="@font/play"
                    android:text="/"
                    android:textColor="@color/black"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/pisly"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:fontFamily="@font/play"
                    android:text="9"
                    android:textColor="@color/black"
                    android:textSize="14sp" />

                <ProgressBar
                    android:id="@+id/progressBar123"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_width="match_parent"
                    android:layout_height="7dp"
                    android:layout_marginLeft="21dp"
                    android:layout_marginTop="15dp"
                    android:progress="50"
                    android:progressDrawable="@drawable/drawable_progress_bar" />

            </LinearLayout>


        </LinearLayout>
    </LinearLayout>
    <ImageView
        android:id="@+id/plus"
        android:clickable="true"
        android:layout_width="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginRight="20dp"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:src="@drawable/addtask15050"
        android:layout_alignParentRight="true" />

    <LinearLayout
        android:id="@+id/listCustom"
        android:orientation="horizontal"
        android:layout_below="@+id/lin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
       />

</RelativeLayout>

Ниже представлен MainActivity.java

package com.example.expenbllistview;


import android.app.Activity;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;


public class MainActivity extends Activity {


    final String DAY="day",
            NUM ="num",
            MONTH = "month",
            IMAGE = "image",
            PROGRESS = "progress",
            DO = "do",
            AFTER = "after";

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       CustomExpandableListView();


    }

    public void CustomExpandableListView(){
        ExpandableListView listView = (ExpandableListView)findViewById(R.id.expListView);


        // Находим наш list
        //Создаем набор данных для адаптера

        ArrayList<ArrayList<String>> groups = new ArrayList<ArrayList<String>>();
        ArrayList<String> monday = new ArrayList<String>();
        ArrayList<String> tuesday = new ArrayList<String>();
        ArrayList<String> wednesday = new ArrayList<String>();
        ArrayList<String> thursday = new ArrayList<String>();
        ArrayList<String> friday = new ArrayList<String>();
        ArrayList<String> saturday = new ArrayList<String>();
        ArrayList<String> sunday = new ArrayList<String>();


        monday.add("Child_1");
        monday.add("Child_2");
        groups.add(monday);


        tuesday.add("Child_1");
        tuesday.add("Child_2");
        tuesday.add("Child_3");
        groups.add(tuesday);


        wednesday.add("Child_1");
        wednesday.add("Child_2");
        wednesday.add("Child_3");
        groups.add(wednesday);


        thursday.add("Child_1");
        thursday.add("Child_2");
        thursday.add("Child_3");
        groups.add(thursday);


        friday.add("Child_1");
        friday.add("Child_2");
        friday.add("Child_3");
        groups.add(friday);


        saturday.add("Child_1");
        saturday.add("Child_2");
        saturday.add("Child_3");
        groups.add(saturday);


        sunday.add("Child_1");
        sunday.add("Child_2");
        sunday.add("Child_3");
        groups.add(sunday);


        //Создаем адаптер и передаем context и список с данными
        ExpandableListAdapter adapter = new MyExpandebleListAdapter(getApplicationContext(), groups);
        listView.setAdapter(adapter);
    }

}

Всем Большое спасибо кто даст ответ!!! Хорошего вам дня


Ответы (0 шт):