Can*_*ğlu 21 android android-actionbar android-studio android-studio-2.0
我在Android Studio中创建了一个Android应用程序,它默认创建了这些样式:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是,在一个活动中,我尝试将其设置为主题:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
android:theme="@style/AppTheme.NoActionBar">
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序时,我正在获取操作栏:
我为什么要一个行动吧?我做了一些明显错误的事情,还是Android工作室,这是谷歌自己平台的官方IDE,试图混淆/误导其开发者?
这是我的活动代码,其中没有任何内容可以导致操作栏自行显示:
public class WelcomeActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_welcome);
}
}
Run Code Online (Sandbox Code Playgroud)
Meh*_*t K 45
尝试这样的事情:
<style name="AppTheme.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并将其设置为清单中活动的主题,即:
<activity
...
android:theme="@style/AppTheme.NoActionBar">
</activity>
Run Code Online (Sandbox Code Playgroud)
没有其他答案对我有用,但我找到了这个解决方案:
values/styles.xml在Android Studio中打开并更改此信息:
<!-- Base application theme. -->
<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>
Run Code Online (Sandbox Code Playgroud)
至:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- changed .DarkActionBar to .NoActionBar -->
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如果您只是让 Android Studio 自动生成活动,请查看activity_welcome. 有android.support.design.widget.AppBarLayout,如果你删除它,ActionBar 应该消失了。
| 归档时间: |
|
| 查看次数: |
52367 次 |
| 最近记录: |