1.该布局为新出现,不支持较早版本,需要在app/build.gradle文件中添加如下内容(黑体部分)
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:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:percent:26.+'
testCompile 'junit:junit:4.12'
}
2.标签中 为<android.support.percent.PercentFrameLayout></>/<android.support.percent.PercentRelativeLayout></>
3.需要添加 xmlns:app="http://schemas.android.com/apk/res-auto"
4.android:layout_gravity="left|top"//设置位置
app:layout_widthPercent="50%"//设置宽(相对于父容器)
app:layout_heightPercent="50%"设置高(相对于父容器)
5.继承了FrameLayout特性