@AntonGoretskiy

Layout c listview при заполнении скрывает элемент над ним, как это исправить?

Добрый день!
Я новичок в разработке под Андроид, второй день пытаюсь реализовать следующее:
db6ad40446fd4ce38d68058b69913587.png
layout1.axml, в нем разметка экрана на котором находится много элементов в ScrollView, эти элементы могут не помещаться на экран, а под ScrollView находится кнопка Button1, которая должна быть всегда видна, даже если в ScrollView много элементов.
layout2.axml, в нем разметка экрана на котором, находится заголовок EditText и под ним ListView, элементов в котором может стать очень много и экран должен прокручиваться.
Layout3.axml, в нем находятся RelativeLayout1, в который с помощью FragmentTrasaction будет помещен layout1, под ним находится Button3 и Button4, а под ними RelativeLayout2, в который будет помещен layout2.
Итоговый экран layout3, должен работать следующим образом:
Вначале видна только RelativeLayout1 и под ним ВСЕГДА, сколько бы места он не занимал, должна быть видна Button3. В этом состоянии Button4(visibility=gone). По нажатии на button3, мне нужно спрятать в layout1 scrollview1, а Button1 сделать видимым, так же в listView2 добавиться много элементов, button3,4 тоже скрываются. После должен получиться экран на котором, есть часть layout1 -button1 и под ним layout2.
Я попытался это реализовать, но после того как в listview2 добавилось много элементов, listview2 занял весь экран, а над ним должна была быть кнопка.
Подскажите пожалуйста как это правильнее реализовать. Заранее благодарен!
Вот мой код:

Итоговый экран:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/blue_bg"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:layout_height="fill_parent">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="100"
        android:id="@+id/pager1"
        android:fillViewport="false"
        android:visibility="visible" />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/bottomPanel"
        android:layout_gravity="center_horizontal"
        android:gravity="center_horizontal">
        <Button
            android:text="Button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/SaveAsSampleFindButton"
            android:background="@drawable/red_button"
            android:textColor="#ffffffff"
            android:layout_margin="5dip"
            android:visibility="gone" />
        <Button
            android:text="Button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/StartFindButton"
            android:background="@drawable/red_button"
            android:layout_below="@id/SaveAsSampleFindButton"
            android:textColor="#ffffffff"
            android:layout_margin="5dip" />
        <RelativeLayout
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/pager2" />
    </LinearLayout>
</LinearLayout>

layout1:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_weight="1">
    <ScrollView
        android:minWidth="25px"
        android:minHeight="25px"
        android:id="@+id/FindOptions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:orientation="vertical"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/queryText"
                android:hint="Ключевое слово" />
				
        </LinearLayout>
    </ScrollView>
    <LinearLayout
        android:orientation="vertical"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:layout_weight="2"
        android:layout_alignParentBottom="true"
        android:id="@+id/UnCollapseFindButtonPanel"
        android:layout_height="wrap_content">
        <Button
            android:text="Развернуть поиск"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/UnCollapseFindButton"
            android:background="@drawable/red_button"
            android:textColor="#ffffffff" />
    </LinearLayout>
</RelativeLayout>


layout2:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@color/blue_bg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="horizontal"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:paddingTop="15dip"
            android:paddingLeft="15dip"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/text_color"
            android:textStyle="bold" />
    </LinearLayout>
    <ListView
        android:minWidth="25px"
        android:minHeight="25px"
        android:paddingLeft="15dip"
        android:paddingRight="15dip"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/procListView" />
</LinearLayout>
  • Вопрос задан
  • 2869 просмотров
Решения вопроса 1
Collosteam
@Collosteam
Android кодирую
Layout1.xml
<?xml version="1.0" encoding="utf-8"?>
    
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        android:id="@+id/FindOptions"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/UnCollapseFindButtonPanel">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/queryText"
                android:hint="Ключевое слово" />
        </LinearLayout>
    </ScrollView>
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:id="@+id/UnCollapseFindButtonPanel"
        android:layout_height="wrap_content">
        <Button
            android:text="Развернуть поиск"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/UnCollapseFindButton"
           android:textColor="#ffffffff" />
    </LinearLayout>
</RelativeLayout>
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

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

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