图像在设备上消失,但在android studio预览中显示

时间:2018-11-29 07:06:22

标签: java android xml android-gradle shapes

我有一个使用XML重新设计的矢量图像。 在Android Studio上的预览中,图像看起来不错,但在设备上似乎消失了。 有什么建议吗?

我的应用程序类中有以下行:AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)

这对我来说很重要:useSupportLibrary = true

在设备上

On Device

预览时:

On Preview

myLayout

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center">

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_centerVertical="true"
        android:background="@color/CoolGrey" />

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/detailsPost_showMoreInfoIB"
        android:layout_width="28dp"
        android:layout_height="28dp"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/ic_chevron_down_blue" />

</RelativeLayout>

ic_chevron_down_blue

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <solid android:color="@color/CoolGrey" />
        </shape>
    </item>
    <item
        android:left="0dp"
        android:right="0dp"
        android:top="0dp"
        android:bottom="0.5dp">
        <shape android:shape="oval">
            <solid android:color="@color/White" />
        </shape>
    </item>
    <item>
        <rotate
            android:drawable="@drawable/ic_chevron_blue"
            android:fromDegrees="-90"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toDegrees="-90" />
    </item>
</layer-list>

ic_chevron_blue

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#0082f2"
        android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
</vector>

app build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.willingapp.willing"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    //Base libs
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'org.glassfish.main.resources:javamail:4.1.1'

    //HTTP Communication
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'


    //Text Handler
    implementation 'org.apache.commons:commons-text:1.3'

    //Fabric
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true;
    }
}

0 个答案:

没有答案