簡體   English   中英

如何在 webview 中禁用工具欄

[英]how to disable toolbar in webview

請幫幫我,我不太懂編程。 我試圖隱藏 webview 中的工具欄。 這是我的源代碼:

@RequiresApi(api = Build.VERSION_CODES.KITKAT)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CookieSyncManager.createInstance(getApplicationContext());
        CookieSyncManager.getInstance().startSync();
        setContentView(R.layout.activity_affiliate_view);

        Toolbar toolbar = findViewById(R.id.toolbar);
        toolbarTextView = findViewById(R.id.toolbarTextView);

        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        toolbarTextView.setText("Product Details");


        progressBar = findViewById(R.id.progressbar);

        progressBar.setVisibility(View.VISIBLE); // To show the ProgressBar

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    

      

    

這是圖像:

您可以在 Themes.xml 文件中創建不帶工具欄的新樣式,並將其應用於清單中的特定活動

主題.xml

<style name="CustomStyle" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="colorPrimary">@color/purple_500</item>
    <item name="colorPrimaryVariant">@color/purple_700</item>
</style>

AndroidManifest.xml

<activity
  android:name=".AffiliateViewActivity"
  android:exported="false"
  android:theme="@style/CustomStyle"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM