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

  • SEARCH
  • Home
  • 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 9206903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:16:32+00:00 2026-06-18T00:16:32+00:00

Hey I am trying to create a header with an image in the center

  • 0

Hey I am trying to create a header with an image in the center and a button at the right corner.

I found this post how to make headers in android with text and buttons like in iOS, and the following tutorial http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/ , and I was able to put the image in the center and set the background. However, no matter what I do my button won’t show up at the right corner.

I tried to see if it was masked by the background or maybe out of the screen, but I could not find the reason for my problem.

my XML

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"> 
        <ImageView
            android:id="@+id/Header"
            android:src="@drawable/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ff000000"
            android:layout_marginTop="5dp"
            android:gravity="center_horizontal"/>

                <Button
            android:id="@+id/lockButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5.0dip"        
            android:text="TEST"
            />


    </LinearLayout>
  • 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-18T00:16:33+00:00Added an answer on June 18, 2026 at 12:16 am

    Why not relative

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/img_vs_navbar" >
    
    <ImageView
        android:id="@+id/img_back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:src="@drawable/btn_setting_back" />
    
    </RelativeLayout>
    

    You can put it in center by using android:layout_centerInParent like this.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/img_vs_navbar" >
    
        <ImageView
            android:id="@+id/img_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:src="@drawable/btn_setting_back" />
    
    </RelativeLayout>
    

    Or use alignParentRight to put it at right

    Edited :

    This one is for using two imageview in one xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/img_vs_navbar" >
    
        <ImageView
            android:id="@+id/img_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/btn_setting_back" />
    
        <ImageView
            android:id="@+id/img_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:src="@drawable/btn_setting_back" />
    
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there! I'm doing this project and right now I'm trying to: create some
Hey, I'm having trouble with this side bar I'm trying to make. It wont
Hey guys I'm trying to create something similar to the image below. As you
Hey guys - I'm tearing my hair out trying to create a regular expression
hey I'm trying to figure out what this element is in an app I
Hey I am trying to make a dungeon crawler and I am stuck on
hey all i am trying to make a data output stream in php to
hey people hope all is well.. i am trying to create a form in
Hey, I have 2 classes. When I'm trying to create an XML structure from
Hey basically Im trying to store a solution and create a vector of these.

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.