A
A
AntonGoretskiy2014-05-23 00:14:34
Android
AntonGoretskiy, 2014-05-23 00:14:34

Layout c listview hides the element above it when filled, how to fix it?

Good afternoon!
I'm new to Android development, the second day I'm trying to implement the following:
db6ad40446fd4ce38d68058b69913587.png
layout1.axml, it has a screen layout on which there are many elements in the ScrollView, these elements may not fit on the screen, and under the ScrollView there is a Button1 button, which should always be visible, even if the ScrollView has many items.
layout2.axml, it contains the layout of the screen on which there is an EditText header and under it a ListView, in which there can be a lot of elements and the screen must scroll.
Layout3.axml, it contains RelativeLayout1, in which layout1 will be placed using FragmentTrasaction, below it are Button3 and Button4, and below them RelativeLayout2, in which layout2 will be placed.
The resulting layout3 screen should work like this:
At the beginning, only RelativeLayout1 is visible, and under it ALWAYS, no matter how much space it takes up, Button3 should be visible. In this state Button4(visibility=gone). By clicking on button3, I need to hide scrollview1 in layout1, and make Button1 visible, so many elements will be added to listView2, buttons3,4 are also hidden. After that, you should get a screen on which there is a part of layout1 -button1 and under it layout2.
I tried to implement this, but after many items were added to listview2, listview2 took up the entire screen, and there should have been a button above it.
Please tell me the best way to implement this. Thanks in advance!
Here is my code:
Final screen:

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey M, 2014-05-23
@AntonGoretskiy

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>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question