0

화면 비율에 비례하여 imagevews의 여백을 설정할 수 있도록 Android 퍼센트 지원 라이브러리를 사용하려고합니다. 이렇게하면 imageViews의 여백에는 아무런 영향을 미치지 않습니다. 다음은 XML 파일입니다.Android percent support library 결과가 생성되지 않습니다.

<?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> 

아래 build.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' 
} 

내가 잘못하고있는 것이 있습니까? 어떤 도움을 주시면 감사하겠습니다. 여기

+0

첫 번째 변경이'buildToolsVersion "24.0.2"''buildToolsVersion "24.2.1"'. 'build'와'support'에 같은 버전을 사용해야합니다. – Ironman

+0

이렇게하면 "빌드 도구 개정판 24.2.1을 찾지 못했습니다"라는 오류 메시지가 나타납니다. 다음 설치를 시도하면 "모든 패키지를 다운로드 할 수 없습니다! 다음 패키지를 사용할 수 없습니다 : -Package id build-tools; 24.2.1"오류가 발생했습니다. 다른 아이디어? – abruzzi26

+0

gridlayout에서 비율 레이아웃을 사용해보십시오. –

답변

0

내가 안드로이드 스튜디오 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' 
    } 

했다> 내가 24.2에 내 빌드 도구 버전을 변경 ProjectStructure> 응용 프로그램> [속성]을 선택합니다. 1 프로젝트를 만들었지 만 패키지에 오류가 발생했습니다. 다시 동일한 접근 방식을 사용하여 24.0.2로 변경하고 프로젝트를 다시 빌드합니다. 기적적으로, 그것은 작동했습니다 ...

관련 문제