XUI项目地址:
XUI
在使用前,请一定要仔细阅读使用说明文档,重要的事情说三遍!!!
在使用前,请一定要仔细阅读使用说明文档,重要的事情说三遍!!!
在使用前,请一定要仔细阅读使用说明文档,重要的事情说三遍!!!
添加Gradle依赖
1.先在项目根目录的 build.gradle 的 repositories 添加:
allprojects {repositories {...maven { url "https://jitpack.io" }}}
2.然后在dependencies添加:(注意:androidx请使用1.0.5之后的版本)
dependencies {...//androidx项目implementation 'com.github.xuexiangjys:XUI:1.1.4'implementation 'androidx.appcompat:appcompat:1.1.0'implementation 'androidx.recyclerview:recyclerview:1.1.0'implementation 'com.google.android.material:material:1.1.0'implementation 'com.github.bumptech.glide:glide:4.11.0'}
如果你的项目目前还未使用androidx,请使用如下配置:
dependencies {...//support项目implementation 'com.github.xuexiangjys:XUI:1.0.9-support'implementation 'com.android.support:appcompat-v7:28.0.0'implementation 'com.android.support:recyclerview-v7:28.0.0'implementation 'com.android.support:design:28.0.0'implementation 'com.github.bumptech.glide:glide:4.8.0'}
初始化XUI设置
1.在这里我们可以自己定义新建一个MyApplication继承Application,在里面的onCreate()方法最顶部初始化设置。
public class MyApplication extends Application {private static Context MyContext;@Overridepublic void onCreate() {super.onCreate();XUI.init(this); //初始化UI框架XUI.debug(true); //开启UI框架调试日志MyContext = getApplicationContext();}}
2.在AndroidManifest.xml中application里面写上android:name=".MyApplication"
3.调整应用的基础主题
public class MainActivity extends AppCompatActivity {protected void onCreate(Bundle savedInstanceState) {XUI.initTheme(this);//加入这行代码super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}}