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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:10:44+00:00 2026-05-18T05:10:44+00:00

My ImageView for some odd reason is always displaying a picture in the middle,

  • 0

My ImageView for some odd reason is always displaying a picture in the middle, left of my screen despite the xml code insisting it to be in the center.

I force portrait orientation in my app and here is my xml code for my layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:gravity="center">

    <ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/image_view"
    android:layout_weight="1.0"/>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/message"
    android:gravity="center_horizontal"
    android:padding="10dip"/>

    <Button
            android:layout_gravity="center_horizontal"
    android:layout_width="fill_parent"
    android:textStyle="bold" android:id="@+id/action_button" android:selectAllOnFocus="false" android:layout_height="100dip" android:text="Click here to preform actions"/>
</LinearLayout>

So, the page should display as Picture in the middle, extending the width of the screen, the text below that and the button below that. But for some reason, the picture is displayed as a small, box thumbnail in the middle left of the screen – any ideas on a workaround?

  • 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-18T05:10:45+00:00Added an answer on May 18, 2026 at 5:10 am

    Assuming you want your picture centered inside a top box here, you don’t want android:gravity="center", you actually just want android:scaleType set on the ImageView itself. “center” is the right value if you don’t want scaling; centerInside is probably appropriate if you do (in which case you’ll need to define some sort of dimensions or weight on your ImageView). For more on scaleType values, see the documentation.

    You also don’t want the image height set to fill_parent, or it will do that (which means no text below it, since the image fills the entire parent LinearLayout leaving no room for text). You probably want the ImageView‘s height set to wrap_content or some fixed height (e.g. 100dip).

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

Sidebar

Related Questions

For some reason, I'm having difficulty aligning ImageView's to the top of the activities
I wrote some xml but still cant place the text on the center of
What are some ideas about having an ImageView that takes up the whole screen
I have a ListView, displaying some items, containing an ImageView filled with a standard
I have imageView with some frame imageView.frame = CGRectMake(0,0, 100, 100); imageView.contentMode = UIViewContentModeScaleAspectFit;
I have a ImageView and draw some things on that view. Now I want
I'm having some trouble with the logic behind storing an ImageView into an ArrayList.
I got a 9 patch image which is the background of some imageview on
I want to give ID to some views (textview ,imageview etc) in a layout
I have a layout which contains some views like this: <LinearLayout> <TextView...> <TextView...> <ImageView

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.