繁体   English   中英

Gridview的最后一行被切断

[英]Gridview last row being cut off

我的物品布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:paddingBottom="16dp"
android:gravity="center">
<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/iv"
    android:adjustViewBounds="true"
    android:src="@drawable/linianzhenti"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tv"
    android:layout_marginTop="8dp"
    android:text="aaa"
    android:textSize="16sp"/>

然后是我的主要布局:

<ScrollView 
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey"
    android:orientation="vertical">
    ...
    ...
    <com.kumakitty.wenquanedu.MyGridView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:horizontalSpacing="16dp"
        android:id="@+id/gridhome2"
        android:numColumns="2">

    </com.kumakitty.wenquanedu.MyGridView>
</LinearLayout>

这是MyGridView.class:

public class MyGridView extends GridView {
public MyGridView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public MyGridView(Context context) {
    super(context);
}

public MyGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int mExpandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, mExpandSpec);
}
}

我用ImageLoader播放了图像,我认为这可能是由于图像高度不同引起的。我该如何解决? 任何帮助将不胜感激:)请原谅我可怜的英语OTL

在ScrollView中使用GridView是非常糟糕的做法。 您可以使用支持所需嵌套滚动效果的最新视图。

请参阅下面的链接,该链接显示了最佳做法:

如何在NestedScrollView中使用RecyclerView?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM