android总结三(新AS打开旧AS项目)

1、解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com

defaultConfig {
   targetSdkVersion:***
   minSdkVersion :***
   versionCode:***
   versionName :***
   //版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了
   flavorDimensions "versionCode"
}

2、Android中Activity和AppcompatActivity

AppcompaActivity相对于Activity的主要的两点变化; 
1:主界面带有toolbar的标题栏; 
2,theme主题只能用android:theme=”@style/AppTheme (appTheme主题或者其子类),而不能用android:style。 否则会提示错误: Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
————————————————

去掉AppcompaActivity的标题栏方法: 
if (getSupportActionBar()!=null){ 
getSupportActionBar().hide(); 

原文链接:https://blog.csdn.net/today_work/article/details/79300181

--------------------------------------------

activity改为AppCompatActivity后崩溃(继承自AppCompatActivity崩溃闪退问题):

activity的style是

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

需要修改为:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

main配置文件中,注册activity时样式也需更改:

android:theme="@style/AppThemeF"

————————————————
 
原文链接:https://blog.csdn.net/moonshine99/article/details/78253696

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值