Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footer view with match_parent width stretching under one cell not entire screen. #5

Closed
kusraevs opened this issue Nov 23, 2014 · 11 comments

Comments

@kusraevs
Copy link

Here is my code:

goodsGridView = (GridViewWithHeaderAndFooter) rootView.findViewById(R.id.goods_grid);
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
goodsFooterView = layoutInflater.inflate(R.layout.good_grid_footer, null);
goodsFooterView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
goodsGridView.addFooterView(goodsFooterView);



screenshot_2014-11-23-13-43-06

@liaohuqiu
Copy link
Owner

Can you paste a screen snapshot with layout bounds?

@kusraevs
Copy link
Author

Thank you for your response. Don't understand what do you mean. To paste footer layout preview screenshot?

@liaohuqiu
Copy link
Owner

qq20141123-1 2x

Go to Settings > Developer options > Show layout bounds

@kusraevs
Copy link
Author

screenshot_2014-11-23-14-42-50

@liaohuqiu
Copy link
Owner

Can you wrap the footer by a ViewGroup, for example:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:text="FOOTER"
        android:layout_marginBottom="10dp"
        android:background="@color/cube_demo_main_color"
        android:gravity="center"
        android:textSize="14dp" />
</FrameLayout>

@kusraevs
Copy link
Author

Yes, i already have done it. I just had problem with putting xml in message.
With your layout i see
screenshot_2014-11-23-15-50-43

@liaohuqiu
Copy link
Owner

It seems like that the footer does not stretch to the full width. Can you push your project or a demo to github, I need more information to solve this issue.

@liaohuqiu
Copy link
Owner

By the way, what is the API level? Android 2.3.7?

@kusraevs
Copy link
Author

No it's api 14 level.
I create a github repository and imported my eclipse project to it.
https://github.com/kusraevs/BlackStore
The fragment with grid located at
src/com/example/blackstore/goods/GoodsListFragment
Thanks for a help.

@liaohuqiu
Copy link
Owner

I checked out your project and tried very hard to make it run in intellij idea...

In fragment_goods_grid.xml:

<?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"
    android:id="@+id/ptr_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#E5E5E5" >

    <com.example.blackstore.goods.GridViewWithHeaderAndFooter
        android:id="@+id/goods_grid"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnWidth="70dp"
        android:gravity="center"
        android:horizontalSpacing="4dip"
        android:numColumns="auto_fit"
        android:padding="2dip"
        android:stretchMode="columnWidth"
        android:verticalSpacing="4dip" />

</LinearLayout>

In GridView, set android:gravity="center" will make its children to layout center in its positon. Delete this line or chang to left. I also will make a release later.

Now it looks like:

image

@kusraevs
Copy link
Author

Thank you! Deleting this line solved the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants