繁体   English   中英

GridView在模拟器上的行为有所不同,并发布了apk

[英]GridView behaves differently on Emulator and release apk

我有一个Gridview,在Emulator上运行良好,但是当我生成带符号的apk(发行版apk)时,gridview中一个元素的高度与其他元素不同。 我不知道我在做什么错。

在我的GridView中,我的命令是这样的:

A B C D

生长激素

J

奇怪的是,元素“ D”也显示为最后一个元素,但是应该在仿真器“ L”上显示元素“ L”,但是当我生成apk时却没有。 这是xml文件:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/android_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:id="@+id/appbar_layout"
    android:layout_height="@dimen/app_bar_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_android_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="@dimen/expanded_toolbar_title_margin_start"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/image_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerInside"
            android:src="@drawable/logonew"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.7"
           />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:id="@+id/nestedscrollview"
    android:layout_height="match_parent"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <GridView
            android:id="@+id/grid"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:columnWidth="100dp"
            android:gravity="center"
            android:numColumns="auto_fit"
            android:stretchMode="columnWidth"
            android:listSelector="#00000000"

            />
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

我认为,模拟器电话的设备宽度与安装发行版APK的设备宽度是不同的。 由于您将columnWidth固定为100dp,因此宽度较大的电话可以容纳视图,而另一部则不能。 创建与安装发行版APK相同的设备的仿真器,然后查看是否也会发生这种情况。 您也可以尝试使用不同的columnWidths。 尝试将其降低为80dp或50dp,然后看看会发生什么。
如果问题仍然存在,请附上两台设备的屏幕截图。

暂无
暂无

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

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