Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:05:57+00:00 2026-06-18T11:05:57+00:00

I am trying to offset a button and have its location be so that

  • 0

I am trying to offset a button and have its location be so that it appears to hang over other elements. What I am looking for can be seen in this image… notice the image button, which is id ibLoginButton in my xml, where the red arrow is pointing:

enter image description here

Here is the xml for my layout, but I do not know how to make ibLoginButton have that effect. Do I need to do this programmatically? If so, how?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/db1_root"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout
        style="@style/TitleBar"
        android:layout_height="54dp">
        <ImageView
            android:id="@+id/ivLoginPicture"
            android:contentDescription="@string/description_logo"
            android:src="@drawable/MDSLogoForLoginTrans"
            android:background="#ffffffff"
            android:layout_width="32dp"
            android:layout_height="44dp"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_centerVertical="true" />
        <TextView
            android:id="@+id/tvLoginName"
            android:text="Dr. Dentist"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="230.5dp"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/ivLoginPicture"
            android:layout_centerVertical="true" />
        <ImageButton
            android:id="@+id/ibLogout"
            android:src="@drawable/logoutButton"
            android:layout_width="80dp"
            android:layout_height="38dp"
            android:layout_gravity="center_vertical"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:scaleType="fitXY"
            android:paddingTop="0dp"
            android:paddingRight="0dp"
            android:paddingBottom="0dp"
            android:paddingLeft="0dp" />
        <ImageButton
            android:src="@android:drawable/ic_menu_gallery"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:id="@+id/ibLoginButton"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />
    </RelativeLayout>
    <LinearLayout
        android:id="@+id/HomePage"
        android:layout_weight="1"
        android:background="@drawable/home_background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <GridView
            android:id="@+id/Grid"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:columnWidth="90dp"
            android:numColumns="auto_fit"
            android:listSelector="@android:color/transparent"
            android:verticalSpacing="10dp"
            android:horizontalSpacing="10dp"
            android:stretchMode="columnWidth"
            android:gravity="center"
            android:scrollbars="vertical" />
    </LinearLayout>
    <WebView
        android:layout_width="fill_parent"
        android:layout_height="100dip"
        android:layout_alignParentBottom="true"
        android:background="@drawable/gradientNews"
        android:id="@+id/webView1" />
</LinearLayout>

Anyone with knowledge of Android Layouts please shed some light!!! I am stumped.

Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:05:58+00:00Added an answer on June 18, 2026 at 11:05 am

    Couple changes that need to be made

    • Need to make the top LinearLayout into a RelativeLayout.
    • Need to move the ibLoginButton button outside of its RelativeLayout
    • ibLoginButton needs to be after both regions it overlays, since items at the bottom of RelativeLayout‘s are drawn on the top.

    Full example code that will give you what you want (looks good in Eclipse’s Graphical Layout preview).

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/db1_root"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <RelativeLayout
            style="@style/TitleBar"
            android:id="@+id/first_relative"
            android:layout_width="wrap_content"
            android:layout_height="54dp" >
    
            <ImageView
                android:id="@+id/ivLoginPicture"
                android:contentDescription="@string/description_logo"
                android:src="@drawable/MDSLogoForLoginTrans"
                android:background="#ffffffff"
                android:layout_width="32dp"
                android:layout_height="44dp"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:layout_centerVertical="true" />
            <ImageButton
                android:id="@+id/ibLogout"
                android:src="@drawable/logoutButton"
                android:layout_width="80dp"
                android:layout_height="38dp"
                android:layout_gravity="center_vertical"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:scaleType="fitXY"
                android:paddingTop="0dp"
                android:paddingRight="0dp"
                android:paddingBottom="0dp"
                android:paddingLeft="0dp" />
    
            <TextView
                android:id="@+id/tvLoginName"
                android:layout_width="230.5dp"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/ibLogout"
                android:text="Dr. Dentist"
                android:textAppearance="?android:attr/textAppearanceMedium" />
    
        </RelativeLayout>
        <LinearLayout
            android:id="@+id/HomePage"
            android:layout_weight="1"
            android:background="@drawable/home_background"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@id/first_relative">
    
            <GridView
                android:id="@+id/Grid"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:columnWidth="90dp"
                android:gravity="center"
                android:horizontalSpacing="10dp"
                android:listSelector="@android:color/transparent"
                android:numColumns="auto_fit"
                android:scrollbars="vertical"
                android:stretchMode="columnWidth"
                android:verticalSpacing="10dp" >
            </GridView>
    
        </LinearLayout>
        <WebView
            android:layout_width="fill_parent"
            android:layout_height="100dip"
            android:layout_alignParentBottom="true"
            android:background="@drawable/gradientNews"
            android:id="@+id/webView1" />
    
        <ImageButton
            android:id="@+id/ibLoginButton"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="22dp"
            android:src="@android:drawable/ic_menu_gallery" />
    
    </RelativeLayout>
    

    As an aside, it should be possible to only use a single relative layout. Using the minimal number of containers is best practice for performance reasons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to append a transparent layer to some elements with an edit button
I'm trying to work with a jQuery script I found at http://marcgrabanski.com/articles/scrollto-next-article-button-jquery that allows
I have a function that when i click a button I call more results
In this example code, I'm trying to offset the Grid 's Canvas position by
I am trying to find offset of all occurrences with preg_match_all e.g. $haystack =
I am trying to get the offset hours from UTC, given a summer date.
I'm trying to get the offset or position of the cursor on a single
I'm trying to read binary data from a specific offset. I write the data
I'm trying to perform hidden line removal using polygon offset fill. The code works
var wdt = document.body.offsetWidth/2.6 var hgt = document.body.offsetHeight/4 $(#element).offset({left:wdt, top:hgt}) what i am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.