GridLayout似乎不在设计视图上

时间:2018-08-15 19:07:25

标签: java android

我试图将ImageView放入GridLayout中,但是在designview上看不到。当我运行该应用程序时,我可以在模拟器屏幕上看到我的图像。通过这种方式,编辑之前在Design View上什么都没出现在styles.xml <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> 上的代码 我使用的是SDK版本28,下面是我的xml文件

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.GridLayout
        android:id="@+id/gridLayout"
        android:layout_width="376dp"
        android:layout_height="463dp"
        android:layout_marginBottom="24dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@mipmap/ic_launcher" />
    </android.support.v7.widget.GridLayout>
</android.support.constraint.ConstraintLayout>

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

1 个答案:

答案 0 :(得分:0)

这是SDK 28中的错误。他们将在以后的更新中解决此问题。可能在其稳定版本发布时。我也遇到了这个问题,我要做的是:

  1. 在模拟器或真实设备上进行测试。

OR

  1. 在SDK 27中编码我的项目(这样我就可以看到布局),并且在设备上进行测试时,我将其更改为SDK 28。