其中工具栏是在BluetoothLeGatt-Android应用程序中创建的

其中工具栏是在BluetoothLeGatt-Android应用程序中创建的,android,Android,我正在使用官方的BluetoothLeGatt-Android应用程序示例。有人知道工具栏(main.xml)是在哪里创建的吗?此外,我还创建了一个登录活动作为应用程序的入口点(即在DeviceScanActivity.java之前)。当我打开应用程序时,我可以看到登录页面。但是,登录页面上也会显示一个工具栏。为什么以及如何移除它 public class LoginActivity extends Activity { @Override protected void onCreate(Bun

我正在使用官方的BluetoothLeGatt-Android应用程序示例。有人知道工具栏(main.xml)是在哪里创建的吗?此外,我还创建了一个登录活动作为应用程序的入口点(即在DeviceScanActivity.java之前)。当我打开应用程序时,我可以看到登录页面。但是,登录页面上也会显示一个工具栏。为什么以及如何移除它

public class LoginActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
}

public void login_btn(View view){
    final Intent intent = new Intent(this, DeviceScanActivity.class);
    startActivity(intent);
}
}


由于默认主题,您看到的栏是活动提供的默认操作栏。正如您所说,这个主题是
Theme.Holo.Light

我建议您尝试将其更改为各种材质设计主题之一:

例如: 编辑你的
主题.xml
并为你的应用程序编辑/创建一个主题:

<style name="Theme.YourTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    
(如果您在
themes.xml
中创建自己的“NoActionBar”主题扩展,可能会更好,比如:

// This is your "default" theme with an ActionBar.
<style name="Theme.YourNormalTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
//这是带有操作栏的“默认”主题。
您可以这样覆盖它:

<style name="Theme.NoActionBar" parent="Theme.MaterialComponents.DayNight.NoActionBar">

或者更好:

   <style name="Theme.YourNormalTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

假的
真的
您还可以使用ThemeOverlay:

<style name="Theme.YourNormalTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

我建议你通过阅读谷歌的雇员来了解主题、风格和属性


或者,您可以全局使用NoActionBar主题,但决定在特定片段/活动中包含一个主题。在这些情况下(以及在大多数情况下),您希望使用NoActionBar主题,并在布局中包含一个
工具栏
(源代码:)并连接它(请参阅文档).

检查AndroidManifest以查看该活动有哪些主题。它最有可能有一个包含工具栏的主题。或者查看
style.xml
themes.xml
。最后但并非最不重要的一点是,如果您链接到此示例所在的存储库,则更容易回答。您好,@martinconcini。感谢您的回复在AndroidManifest中,它使用了
android:label=“@string/app_name”android:theme=“@android:style/theme.Holo.Light”
。如果删除它们,工具栏会有黑色背景和com.example.android.bluetoothlegatt.L.。(太长,无法看到全名)。(1)如何完全删除所有活动的工具栏(2)如何删除第一页的工具栏,但保留所有其他页面的工具栏?BluetoothLeGatt示例GitHub链接是。谢谢!
<style name="Theme.YourNormalTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />