Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

java - GridView blowing screen borders in Android Studio

First of all I hope you've had a great holiday and fun new years eve eventhough there is a pandemic.

I am developing an app as part of a project. But I seem to have some problems with the GridView. When I inflate it with items it goes beyond the borders of the screen. This is when scrolled the top. As you can see the top of the GridView is beyond the borders of the screen. This is when scrolled to the bottom. As you can see the bottom of the GridView is also beyond the borders of the screen. I think it might have something to due with a navigationbar fragment that I have in the bottom. In XML they are both defined as following:

<GridView
        android:id="@+id/gridView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:columnWidth="100dp"
        android:numColumns="1"
        android:stretchMode="columnWidth"

        app:layout_constraintBottom_toTopOf="@id/nav_bar_container"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"

        android:verticalSpacing="10dp"
        />

    <LinearLayout
        android:id="@+id/nav_bar_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">
    </LinearLayout>

And my inflater for the GridView works as following:

if (gridView == null) {
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            gridView = inflater.inflate(R.layout.profile_friend_item, null);
        }

Don't know if anyone has tried the problem, but hope that someone will be able to help.

Best regards Sejr

PS: The generated profiles range from [0-9] and if you need any more details please hit me up. I will happily share them. :)

question from:https://stackoverflow.com/questions/65617491/gridview-blowing-screen-borders-in-android-studio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...