Android 布局error总结

1. drawable里面图片名字不能大写开头

2.Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.RuntimeException: Some file crunching failed, see logs for details

这个错误一般出现在改过图片的后缀名。。。。改回去就好。

3. 想要用百分比布局

首先在app/build.gradle中添加

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:24.2.1'

compile 'com.android.support:percent:24.2.1 //注意这里要对应sdk下的版本,查看~/Library/Android/sdk/extras/android/m2repository/com/android/support/percent里对应的percent版本号

'testCompile 'junit:junit:4.12'

}

4. draw9patch.bat已经在android studio里面集成了。。直接就可以用,害我一顿海找

5.为了使用9patch,我先将图片加入到drawable里面,然后右键-->create 9-patch file。结果每次出现的都是全黑的图,根本没法设置拉伸或者内容区域。而且所有带颜色的图还不能生成。。。

解决方法:直接在外部先把图片变为9-patch file,直接改后缀名为.9.png即可,再在Android studio里面打开即可正常编辑。

 
原文地址:https://www.cnblogs.com/developerchen/p/9287687.html