简体   繁体   English

删除活动中的标题栏也会删除图像

[英]Removing title bar in an activity removes images also

I have this code in my layout class requestWindowFeature(Window.FEATURE_NO_TITLE) to remove the title bar. 我的布局类requestWindowFeature(Window.FEATURE_NO_TITLE)有此代码,以删除标题栏。 It is working fine as it is removed the title bar. 删除标题栏后,它工作正常。 But unfortunately, it also removes the images I put inside the activity. 但不幸的是,它也删除了我放入活动中的图像。

I am using constraint layout and I already infer constraint. 我正在使用约束布局,并且我已经推断出约束。 I also tried putting inside my manifest on application level the android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" code, but whenever I run the app, it says application has stopped. 我还尝试将清单android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"代码放入应用程序级别,但是每当我运行该应用程序时,它都表示应用程序已停止。

Please help. 请帮忙。 Thank you. 谢谢。

To hide title bar for specific activity do this set these lines in onCreate on the activity class 要隐藏特定活动的标题栏,请在活动类的onCreate中设置这些行

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().setDisplayShowTitleEnabled(false);

and in activity layout 和活动布局

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@android:color/transparent"
    app:popupTheme="@style/AppTheme.PopupOverlay" />

and remove AppBarLayout 并删除AppBarLayout

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"/>

Put these lines in your activity - onCreate method - 将这些行放入您的活动-onCreate方法-

super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

Then add android:theme="@style/AppTheme.NoActionBar" 然后添加android:theme="@style/AppTheme.NoActionBar"

in your manifest file look like - 清单文件中的内容如下所示

<activity
            android:name=".EmailValidation"
            android:configChanges="keyboardHidden|screenSize|orientation"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="adjustPan|stateHidden" />

I hope this will be help you. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM