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 7022489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:35:21+00:00 2026-05-27T23:35:21+00:00

I have the following xml file for navigation bar layout: navigation_bar.xml EDIT: I simplified

  • 0

I have the following xml file for navigation bar layout:

navigation_bar.xml

EDIT: I simplified this layout by removing table layout. but sill….

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/NavigationBar" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="45dp"
        android:layout_marginLeft="10dp"
        android:src="@drawable/htc" />

    <TextView
        android:id="@+id/dummy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />

    <Button
        android:id="@+id/btn_home"
        style="@style/NavigationButton"
        android:layout_marginRight="10dp"
        android:drawableTop="@drawable/btn_home"
        android:text="" />

</LinearLayout>

and the following is my styles.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="NavigationBar">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">45dp</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:background">@drawable/top</item>
        <item name="android:dither">true</item>
    </style>


    <style name="NavigationButton">
        <item name="android:layout_gravity">center_vertical</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:drawablePadding">2dp</item>
        <item name="android:background">@null</item>
    </style>   

</resources>

Also, following is the drawable button: btn_home.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/home_pressed"
        android:state_focused="true"
        android:state_pressed="true" />
    <item android:drawable="@drawable/home_pressed"
        android:state_focused="false"
        android:state_pressed="true" />
    <item android:drawable="@drawable/home_selected" android:state_focused="true" />
    <item android:drawable="@drawable/home_default"
        android:state_focused="false"
        android:state_pressed="false" />
</selector>

And I get the following result:

Screenshot of result

See, the home button is displayed on top. But I want it to be center vertically. For that, I specified <item name="android:layout_gravity">center_vertical</item> on styles.xml file. I tried android:layout_gravity="center_vertical|left" also on navigation_bar.xml. But no result. How can I get the home picture to the center? Any help is appreciated!

  • 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-05-27T23:35:21+00:00Added an answer on May 27, 2026 at 11:35 pm

    At last I found a solution, although I don’t feel it’s best. Here is the solution I found out.

    Using the values wrap_content, fill_parent, match_parent are all useless here. They always put the image on top whatever values I set for android:layout_gravity and android:gravity. And, at last, specifying the size of image as height has done the trick.

    This is the new style for NavigationButton from styles.xml

    <style name="NavigationButton">
        <item name="android:layout_gravity">center_vertical</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">25dp</item>
        <item name="android:background">@null</item>
    </style>   
    

    See the layout_height? It is now 25dp. Also, following is the Button entry from navigation_bar.xml.

    <Button
        android:id="@+id/btn_home"
        style="@style/NavigationButton"
        android:layout_marginRight="10dp"
        android:drawableTop="@drawable/btn_home" />
    

    And the result is

    Result of specifying exact height

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

Sidebar

Related Questions

friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have the following xml file <Layout xmlns=http://tempuri.org/Layout/> <Numeric Id=temperature Caption=Temperature> <validation:IsValidWhen xmlns:validation=http://tempuri.org/Validation/> </validation:IsValidWhen>
I have the following XML file: <?xml version=1.0?><!--This document contains the profiles that have
I have the following XML file containing letter and word definitions in this format
I have the following xml file: <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo>
I have the following in an XML file: <entry> ... <link href=http://www.example.com/somelink /> ...
I have the following text in xml file: <Config Builder=LP Wizard> <Libraries> <Library Name=XCAMSource/>
I have the following contents in my XML file: <items> <item id=1><content><![CDATA[<p>string</p>]]></content></item> </items> I
If i have the following directory structure: Project1/bin/debug Project2/xml/file.xml I am trying to refer

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.