如何在 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 文件中创建不带工具栏的新样式,并将其应用于清单
中的特定 activity
themes.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"/>
我想在 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 文件中创建不带工具栏的新样式,并将其应用于清单
中的特定 activitythemes.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"/>