Android %支持库不产生结果



我正在尝试使用Android百分比支持库,以便我可以将imageVIews的边距设置为与屏幕大小成比例。这样做对imageViews的边距没有影响。下面是我的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <GridLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@drawable/white">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column = "0"
            android:layout_row = "0"
            app:srcCompat="@drawable/a"
            android:id="@+id/a"
            app:layout_marginRightPercent="15%" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column = "1"
            android:layout_row = "0"
            app:srcCompat="@drawable/b"
            android:id="@+id/b"
            app:layout_marginRightPercent="15%"/>
    </GridLayout>
</android.support.percent.PercentRelativeLayout>  

我在构建中包含了依赖项。Gradle文件如下。

apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.abruzzi.alphabet"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:percent:24.2.1'
    testCompile 'junit:junit:4.12'
}

我做错了什么吗?如有任何帮助,不胜感激。

这是我如何得到我的工作在android studio 2.2,我有一个类似的配置为urs

android {
compileSdkVersion 24
buildToolsVersion '24.0.2'
defaultConfig {
    applicationId "com.software.praescient.socialdev"
    minSdkVersion 12
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
  }
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
compile 'com.android.support:percent:24.2.1'
  }

我点击File>ProjectStructure>App>Properties,我将构建工具版本更改为24.2.1,并构建了项目,但得到了包失败的错误。我使用相同的方法将其更改回24.0.2,并再次构建项目。

最新更新