-
对于老项目的使用,AndroidAutoSize 可以和 AndroidAutoLayout 一起使用,因为 AndroidAutoLayout 使用的是 px,所以 AndroidAutoSize 对它不会产生任何影响,如果老项目的某些页面之前使用了 dp 进行布局,并且 AndroidAutoSize 对这些页面已经产生了不良影响,可以让之前使用了 dp 的旧 Activity 实现 CancelAdapt 取消适配
implementation 'me.jessyan:autosize:0.7.0'
- 请在 AndroidManifest 中填写全局设计图尺寸 (单位 dp)
<manifest>
<application>
<meta-data
android:name="design_width_in_dp"
android:value="360"/>
<meta-data
android:name="design_height_in_dp"
android:value="640"/>
</application>
</manifest>
- 当某个页面的设计图尺寸与在 AndroidManifest 中填写的全局设计图尺寸不同时,可以实现 CustomAdapt 接口扩展适配参数
public class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {
@Override
public boolean isBaseOnWidth() {
return false;
}
@Override
public float getSizeInDp() {
return 667;
}
}
- 当某个页面想放弃适配,请实现 CancelAdapt 接口
public class CancelAdaptActivity extends AppCompatActivity implements CancelAdapt {
}
-keep class me.jessyan.autosize.** { *; }
-keep interface me.jessyan.autosize.** { *; }
- Email: [email protected]
- Home: http://jessyan.me
- 掘金: https://gold.xitu.io/user/57a9dbd9165abd0061714613
- 简书: http://www.jianshu.com/u/1d0c0bc634db
Copyright 2018, jessyan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.