Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android webview中添加顶部和底部菜单栏_Android_Menu - Fatal编程技术网

如何在android webview中添加顶部和底部菜单栏

如何在android webview中添加顶部和底部菜单栏,android,menu,Android,Menu,我正在使用android应用程序。我创建了一个web视图。现在我想在我的应用程序中添加顶部和底部菜单栏,如页眉和页脚。。我的应用程序以启动屏幕开始,然后是web视图。如何将这些菜单添加到这些web视图的顶部和底部。。???请帮帮我,谢谢 这是我的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/r

我正在使用android应用程序。我创建了一个web视图。现在我想在我的应用程序中添加顶部和底部菜单栏,如页眉和页脚。。我的应用程序以启动屏幕开始,然后是web视图。如何将这些菜单添加到这些web视图的顶部和底部。。???请帮帮我,谢谢

这是我的xml

      <?xml version="1.0" encoding="utf-8"?> 
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"
     android:id="@+id/layout"
        > 
       <ImageView 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:scaleType="center" 
            android:src="@drawable/appinc" 
            android:visibility="visible" 
        /> 
       <WebView android:id="@+id/webview" 
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent" 
        android:visibility="gone" 
        />

      <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="114dp" />

   </RelativeLayout> 

如果您选择的是“菜单号”选项,则无法更改菜单的位置。见此:

不过,您实际上可以使用M在4.0+版本或更高版本中拆分您的action barin。通过拆分操作栏,菜单将同时出现在顶部和按钮中,如下所示:

如果这是你想要的:遵循这个

更新: 我找到了另一个选择!如果你想要这样的菜单 如果需要这些溢出3点图标:

如果这些都不适合您的需要,您可能应该创建自定义视图并根据您的选择进行修改


希望这有帮助

要在xml中应用,请尝试:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="center"
        android:src="@drawable/appinc"
        android:visibility="visible" />

    <LinearLayout
        android:id="@+id/bottom_bar"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_alignParentBottom="true"
        android:background="#550055" >
    </LinearLayout>

    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/bottom_bar" />

    <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/progressBar1"
        android:layout_below="@id/image"
        android:visibility="visible" />

</RelativeLayout>

您应该使用android:layout_weight=0dp

android为我们提供了许多组件,使我们能够快速、优质地开发应用程序。TextView、ImageView等是android中通用且重要的组件。在本教程中,您将阅读如何在Android视图的顶部和底部添加边框。android视图的边框可以通过几种方式添加。在这里,我将展示一种最简单的方法,将边框添加到Android[TextView,Button]视图中。所以,请仔细检查下面的内容

您需要在res/drawable目录中构建一个XML可绘制文件以添加边框。这是在安卓2.2及更高版本中实现的

在Android视图的顶部和底部添加边框的分步指南

1:XML可绘制文件

首先,您需要在/res/drawable文件夹(如/res/drawable/border\u top\u bottom.XML)中创建一个XML可绘制文件border\u top\u bottom.XML,并将其链接到TextView。您的可绘制XML文件如下所示


你能发布你的xml吗?@niko我怎样才能在这个xml中添加顶部和底部栏?经过长时间的搜索,这可能是你唯一的选择。请查看发布问题的人发布的图片。我也会更新我的答案。我不想添加像链接一样的菜单,它完全可以通过使用拆分操作栏来实现,就像我之前建议的那样。我想他们也使用了这个功能。使用拆分动作栏后,您必须添加自定义动作栏,并使用自定义动作按钮和自定义来实现该UI。有关actionbar的详细信息和您需要了解的一切,请参阅。谢谢大家!@ptm图像在哪里?再次检查问题更新了xml,现在它有顶部图像、下面的WebView、WebView下面的ProgressBar和底部的底部栏尝试清理/刷新项目时出错