user2959025
user2959025

Reputation:

How to add top and bottom menu bar in android webview

here is the sample image i want to do..so i need the bottom menus.I am working with android app..I created a web view.Now I want to add top and bottom menu bar like header and footer to my app.. my app start with a splash screen..then followed by web view .how can I add these menu to top and bottom of these web view..??? please help me and thanks.

here is my 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> 

Upvotes: 0

Views: 11632

Answers (4)

Anup SIngha
Anup SIngha

Reputation: 1

Android gives us many components to make a fast and premium application. TextView, ImageView, etc are the general and important components in android. In this tutorial, you will read to add a border to the top and bottom of an Android view. Border to the android views can be added in several ways. Here, I am going to show the easiest and simplest method to add the border to the Android [TextView, Button] views. So, Just Check this below carefully/.

You need to build an XML drawable file inside res/drawable directory For adding the border. This is worked in android 2.2 and higher.

Adding Border to the Top and Bottom of an Android View

Step By Step Guide to Add Border to the Top and Bottom of an Android View

#1: XML Drawable File

First, you need to create an XML drawable file border_top_bottom.xml in /res/drawable folder like /res/drawable/border_top_bottom.xml and link it to TextView. Your drawable XML file will look like this.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <stroke
                android:width="2dp"
                android:color="#e10606" />
            <solid android:color="#9bce64" />
        </shape>
    </item>

    <item
        android:bottom="2dp"
        android:top="2dp">
        <shape android:shape="rectangle">
            <stroke
                android:width="2dp"
                android:color="#9bce64" />
        </shape>
    </item>

</layer-list>

border_top_bottom.xml hosted with ❤ by GitHub

#2: XML Layout File

Following is the content of XML layout file where I have added a TextView.

res/layout/top_bottom_border_in_android_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="16dp"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Adding Border in Top and Bottom of View" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:background="@drawable/border_top_bottom"
        android:padding="30dp"
        android:text="Top Bottom Border in TextView"
        android:textColor="#000000"
        android:textSize="18sp" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:background="@drawable/border_top_bottom"
        android:text="Top Bottom Border in Button" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:autoLink="web"
        android:gravity="center|bottom"
        android:text="ViralAndroid.com"
        android:textSize="25sp"
        android:layout_marginTop="8dp"
        android:textStyle="bold" />
</LinearLayout>

top_bottom_border_in_android_view.xml hosted with ❤ by GitHub

#3: Strings.xml File

res/values/strings.xml

<resources>
  
    <string name="app_name">Adding Border to the Top and Bottom of an Android View</string>
    
</resources>

strings.xml hosted with ❤ by GitHub

Now, run your Adding Border to the Top and Bottom of an Android View application, you will see the border at the top and bottom of TextView.

Upvotes: 0

Beginner
Beginner

Reputation: 85

You should use the android:layout_weight="0dp"

Upvotes: 0

Niko
Niko

Reputation: 8143

To apply in your xml try:

<?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>

Upvotes: 0

Bipin Bhandari
Bipin Bhandari

Reputation: 2692

If you are taking about option menu no you cannot change position of menus. See this: https://stackoverflow.com/a/8236188/2741586

However you can actually split you action bar(in 4.0+ versions or older usingmActionBarSherlock). By splitting action bar, menu will appear in both top and button like this: enter image description here.

If this is what you want: Follow this link

UPDATE: I found another option! If you want menu like this Google Play If you want these overflow 3 dot icons: Follow this link.

If none of these suits with your need, you should probably create custom view and modify according to your choice!

Hope this helps!

Upvotes: 0

Related Questions