当操作栏打开时,Webview 不适合全屏
我想让网络视图全屏显示,操作栏位于其顶部,标准菜单栏位于底部。没有操作栏时它可以正确显示。当我打开它时,网络视图的底部显示在底部菜单栏下,我想将它放在两个菜单栏之间。 它可能很容易修复,但找不到答案。 谢谢!
代码:
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layerType="software"
/>
</RelativeLayout>
settings.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group1">
<item android:id="@+id/opt" android:android:showAsAction="ifRoom|withText" android:enabled="true" android:title="Option 1" android:visible="true"></item>
<item android:id="@+id/opt2" android:showAsAction="ifRoom|withText" android:enabled="true" android:title="Option 2" android:visible="true"></item>
</group>
</menu>
活动:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.settings, menu);
this.menu = menu;
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
return true;
}
I want to have webview displayed fullscreen with action bar on top of it and standard menu bar on bottom. It's displayed correctly without action bar. When I am turning it on, bottom part of webview is displayed under bottom menu bar and I want to fit it between both menu bars.
Its probably easy fix but can't find answer on that.
Thanks!
Code:
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layerType="software"
/>
</RelativeLayout>
settings.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group1">
<item android:id="@+id/opt" android:android:showAsAction="ifRoom|withText" android:enabled="true" android:title="Option 1" android:visible="true"></item>
<item android:id="@+id/opt2" android:showAsAction="ifRoom|withText" android:enabled="true" android:title="Option 2" android:visible="true"></item>
</group>
</menu>
activity:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.settings, menu);
this.menu = menu;
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
return true;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有关操作栏的更多信息,请阅读:http://developer.android.com/guide /topics/ui/actionbar.html
More about Actionbars can be read here: http://developer.android.com/guide/topics/ui/actionbar.html
使用相对布局以便以正确的方式适应事物。
向我们展示更多代码以获得更好的答案:D
MOD
选项菜单通常不是为了适应而制作的进入你的布局,但重叠它。我告诉你考虑创建一个固定的真实菜单,只要你想通过一些操作就可以隐藏它。
还认为菜单不能有固定的大小,它可能会随着方向、手机、Android 版本而变化。然后,如果您可以制作您需要的内容,那么与制作自定义布局相比,您的布局会遇到更多问题。
Use Relative Layout in order to fit things in the right way.
Show us more code in order to obtain for a better answer :D
MOD
Options menu is not made usually for fit into your layout , but overlapping it . I tell you to consider creating a fixed real menu which hides whenever you want with some action.
Also think that menu can't have a fixed size and it may change with orientation , mobile phone , android version . Then if you could made what you need , you'll have more problems with your layout than making a custom one.