使用 AndroidStudio 新建的工程默认用 AppCompatActivity ,是带标题栏的。
记录下 修改标题栏名称 和 隐藏标题栏 的方法。
修改标题栏名称
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm_test);
    Objects.requireNonNull(getSupportActionBar()).setTitle(“Your Title”);
}
 
Objects.requireNonNull 是 AS 报黄后提示的操作。
隐藏标题栏
hide
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm_test);
    Objects.requireNonNull(getSupportActionBar()).hide();
}
 
Theme
试试在 AndroidManifest 中指定 theme 为 NoTitleBar 。
使用 android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" 不行,会报错,
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
 
那就用 Theme.AppCompat ,
android:theme="@style/Theme.AppCompat.NoActionBar"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
 
这三个的效果不如人意,上图,三个分别对应 第 3 、4、5个。
 
 老老实实用 hide 方法吧,
 





![[python爬虫] 爬取图片无法打开或已损坏的简单探讨](https://img-blog.csdnimg.cn/e3f86507aff04704bf5d06498eb0c4d9.png)













