How do I set the listview to its original position?

I've spent enough time to get it to work for my list in setProperty " above

" layout whichalign_parentBottom=true.

Seems very easy? No, it is not.

Please view this image so you can visualize the problem and have some idea of ​​it.

enter image description here

When user scrolls listview

, home button @bottom is hidden.

And by default the home button remains as it is when the scrolling list is idle. This needs to be done.

So my problem is that after the home button Visibility

goes GONE

and then listview

fills all the space towards the bottom MATCH_PARENT

, that's fine.

But when the scroll is pending and Visibility

set to Visible

, then the last list item is viewed / hidden behind the home button.

This means it listview

does not end up in the original location as the image shows.

I tried to programmatically set the property "above" the list, since the "Home" button is align_parentBottom=true

.

also tried changing the whole layout to linear layout and give weight=1

.

But it didn't work out. Any help would be appreciated.

Thank.

Fragment of the layout file:

<LinearLayout
    android:id="@+id/llmain"
    android:visibility="visible"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <TextView
        android:id="@+id/txtTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/d_10"
        android:layout_marginTop="@dimen/d_5"
        style="@style/text_size_title"
        android:textColor="@color/black"
        android:textStyle="bold" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/d_10"
        android:layout_marginRight="@dimen/d_10"
        android:layout_marginTop="@dimen/d_5">

        <TextView
            android:id="@+id/txtDateTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/comment_n_time_color_text"
            android:textSize="14sp" />

        <LinearLayout
            android:layout_width="@dimen/d_1"
            android:layout_height="match_parent"
            android:layout_marginLeft="@dimen/d_3"
            android:layout_marginRight="@dimen/d_3"
            android:background="@color/comment_n_time_color" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:src="@drawable/ic_like" />

        <TextView
            android:id="@+id/txtLike"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/d_3"
            android:layout_marginRight="@dimen/d_3"
            android:textColor="@color/comment_n_time_color_text"
            android:textSize="14sp" />

        <LinearLayout
            android:layout_width="@dimen/d_1"
            android:layout_height="match_parent"
            android:layout_marginLeft="@dimen/d_3"
            android:layout_marginRight="@dimen/d_3"
            android:background="@color/comment_n_time_color" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:src="@drawable/comment" />

        <TextView
            android:id="@+id/txtComment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/d_3"
            android:layout_marginRight="@dimen/d_3"
            android:textColor="@color/comment_n_time_color_text"
            android:textSize="14sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/article_detail_separator"
        android:layout_marginTop="@dimen/d_5"
        android:background="@color/comment_n_time_color"></LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/d_10"
        android:layout_marginTop="@dimen/d_5"
        android:text="@string/article_comment"
        android:textAppearance="?android:textAppearanceMedium"
        android:textColor="@color/black"
        android:textStyle="bold" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/d_10"
        android:layout_marginRight="@dimen/d_10"
        android:layout_marginTop="@dimen/d_5"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/txt_message"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/d_10"
            android:layout_weight="1"
            android:hint="@string/article_comment_hint"
            android:textColor="@color/black" />

        <ImageView
            android:id="@+id/img_send"
            android:padding="@dimen/d_10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:src="@drawable/send_button" />

    </LinearLayout>

    <ListView
        android:id="@+id/listview_comments"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:cacheColorHint="@null"
        android:listSelector="@null">
    </ListView>
</LinearLayout>

      

And the layout of my activity:

<?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"
    android:orientation="vertical"
    android:id="@+id/parent"
    android:background="@android:color/white">

    <include
        android:id="@+id/toolbaar"
        layout="@layout/partial_toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_alignParentTop="true" />

    <View
        android:layout_below="@+id/toolbaar"
        android:id="@+id/viewline"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="@color/separator_color" />

    <FrameLayout
        android:layout_above="@+id/llbottom"
        android:layout_below="@+id/viewline"
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></FrameLayout>

    <LinearLayout
        android:id="@+id/llbottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

        <include
            android:id="@+id/img_home_"
            layout="@layout/home_icon_footer"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</RelativeLayout>

      

+3


source to share


3 answers


I will fix this problem

listview.scrollTo (0, homeBtn.getHeight ());



Which actually moves my list items to scroll up in the Y direction when I get the last item or say when there is no first item in the list.

0


source


I think you can solve your problem by having one parent view, just say a relative view, and then three different views inside that relative view . So it would look like a relative view, and then on the inside, that you can have a view for your items above the View list, and then a ScrollView with your list inside, and finally another view, perhaps a relative view, after that for a button. " home "and make sure before align_parentBottom = true .



0


source


You have to put one layout (Linearlayout) at the bottom with "Wrap_content" and by -_parentbottom = true and inside this layout put your house at the bottom. Now when you set the visibility of the Ready button to the GONE layout, your layout is still there at 0 height, and when you make its inner pad visible, the list doesn't cover the whole part.

0


source







All Articles