应用程序在棉花糖中没有显示任何内容。在棉花糖及以上它可以正常工作

时间:2018-08-11 12:26:26

标签: android android-gridlayout

我正在与Gridlayout一起构建ImageViews和TextView的图块。该应用在Android 6.0上运行良好。但是在低于6.0的版本中,该应用程序只会显示空白的空白屏幕。请帮帮我。谢谢

这是xml文件。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.mrvirk.urduapp.MainActivity"
android:weightSum="8">


<GridLayout


    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="2"
    android:rowCount="4">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:background="@color/green3"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >

            <ImageView
                android:id="@+id/learning"
                android:layout_width="match_parent"
                android:layout_height="@android:dimen/notification_large_icon_width"
                android:scaleType="fitCenter"
                android:src="@drawable/learning"
                android:layout_gravity="center"
                />


        <TextView
            android:id="@+id/txtLearning"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Learning"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:background="@color/yellow"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >


            <ImageView
                android:id="@+id/acheivements"
                android:layout_width="match_parent"
                android:layout_height="@android:dimen/notification_large_icon_width"
                android:scaleType="fitCenter"
                android:src="@drawable/acheivements"

                />


        <TextView
            android:id="@+id/txtAcheivements"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Acheivements"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnSpan="2"
        android:layout_rowWeight="1"
        android:layout_columnWeight="1"
        android:background="@color/red"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >

        <ImageView
            android:id="@+id/quiz"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter"
            android:src="@drawable/quiz" />

        <TextView
            android:id="@+id/txtQuiz"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Quiz"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:background="@color/blue2"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >

        <ImageView
            android:id="@+id/setting"
            android:layout_width="match_parent"
            android:layout_height="@android:dimen/notification_large_icon_width"
            android:scaleType="fitCenter"
            android:src="@drawable/setting" />

        <TextView
            android:id="@+id/txtSetting"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Setting"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:background="@color/tea"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >

        <ImageView
            android:id="@+id/share"
            android:layout_width="match_parent"
            android:layout_height="@android:dimen/notification_large_icon_width"
            android:scaleType="fitCenter"
            android:src="@drawable/share" />

        <TextView
            android:id="@+id/txtshare"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Share"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:background="@color/org"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >

        <ImageView
            android:id="@+id/about"
            android:layout_width="match_parent"
            android:layout_height="@android:dimen/notification_large_icon_width"
            android:scaleType="fitCenter"
            android:src="@drawable/about" />

        <TextView
            android:id="@+id/txtAbout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="About"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:background="@color/green3"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_margin="1dp"
        >

        <ImageView
            android:id="@+id/moreApps"
            android:layout_width="match_parent"
            android:layout_height="@android:dimen/notification_large_icon_width"
            android:scaleType="fitCenter"
            android:src="@drawable/moreapps" />

        <TextView
            android:id="@+id/txtMoreApps"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="More Apps"
            android:textColor="@color/white"
            android:textStyle="bold" />

    </LinearLayout>
</GridLayout>

这是模拟器上的视图。在实际设备上,它仍然相同。

Here is the view on emulator. On real device its still the same.

成绩文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    defaultConfig {
        applicationId "com.example.mrvirk.urduapp"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:21.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

您使用的属性如下:

<picture>
  <source media="(min-width: 120em)" srcset="bg-1920px.webp, bg-1920px@2x.webp 2x" type="image/webp">
  <source media="(min-width: 90em)" srcset="bg-1440px.webp, bg-1440px@2x.webp 2x" type="image/webp">
  ...
  <source media="(min-width: 120em)" srcset="bg-1920px.jpg, bg-1920px@2x.jpg 2x" type="image/jpeg">
  <source media="(min-width: 90em)" srcset="bg-1440px.jpg, bg-1440px@2x.jpg 2x" type="image/jpeg">
  ...
  <img src="small.jpg" alt="My amazing background image">
</picture>

仅适用于api> = 21

确保您的毕业证书中有:

 mydict = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6}
 input_pattern = np.array([['a', 'f'], ['b', 'e'], ['c', 'd']])
 expected_output = np.array([[1, 6], [2, 5], [3, 4]])

或更高版本
并在xml中将 android:layout_columnWeight="1" android:layout_rowWeight="1" 标记替换为

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:gridlayout-v7:27.1.1'