A low-cost Android screen adaptation solution.
今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案.
Overview
Download
implementation 'me.jessyan:autosize:0.6.0'
Usage
Step 1
In AndroidManifest:
<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>
Step 2
In Application:
public class BaseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AutoSizeConfig.getInstance()
.setLog(true)
.init(this)
.setUseDeviceSize(false);
}
}
Advanced
Customize the adaptation parameters of the Activity
public class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {
@Override
public boolean isBaseOnWidth() {
return false;
}
@Override
public float getSizeInDp() {
return 667;
}
}
Cancel the adaptation of the Activity
public class CancelAdaptActivity extends AppCompatActivity implements CancelAdapt {
}
ProGuard
-keep class me.jessyan.autosize.** { *; }
-keep interface me.jessyan.autosize.** { *; }
Donate
About Me
- Email: jess.yan.effort@gmail.com
- Home: http://jessyan.me
- 掘金: https://gold.xitu.io/user/57a9dbd9165abd0061714613
- 简书: http://www.jianshu.com/u/1d0c0bc634db
License
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.