Reputation: 129
I'm trying to use PercentRelativeLayout to obtain a ratio for my widget. Even if I updated the dependecies, it doesn't seem that Android Studio recognize that Library.
Here is my gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.cobaltsign.androidwidget"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'joda-time:joda-time:2.9.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-appindexing:9.0.2'
compile 'com.makeramen:roundedimageview:2.2.1'}
Any idea ?
Upvotes: 0
Views: 2836
Reputation: 6656
In my case I had to use app:layout_widthPercent="100%"
instead of android:layout_width="match_parent"
in order to have ratio like 1:2 with this one app:layout_aspectRatio="200%"
.
Resultant layout is:
<FrameLayout
android:background="@color/black_25"
app:layout_aspectRatio="200%"
app:layout_widthPercent="100%" />
Upvotes: 0
Reputation: 1544
You have to import compile 'com.android.support:percent:23.3.0'
in your build.gradle
. Take a look at this example :
<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">
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
Upvotes: 4