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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:03:36+00:00 2026-05-23T04:03:36+00:00

In my code, I re-size a bitmap and then use the bitmap in my

  • 0

In my code, I re-size a bitmap and then use the bitmap in my code using imageView.setImageBitmap(). However, for some reason the image will not be at the top of the layout, rather it ends up in the center of the screen ( http://imageshack.us/photo/my-images/841/ssbluepic.png/ )

Here is the code for my layout file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"
     xmlns:android="http://schemas.android.com/apk/res/android">

 <!--   <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" 
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:id="@+id/textView1"></TextView>


    <TextView android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:id="@+id/textView2"></TextView>  -->



    <ImageView android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:id="@+id/imageView1" 
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"></ImageView>
</RelativeLayout>

(the two TextViews are commented out).

Any help with this would be much 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-23T04:03:37+00:00Added an answer on May 23, 2026 at 4:03 am

    I used your XML-file and the following java code. The positioning of the image at the top works fine. Probably something wrong with your java code.

    package com.androidplant.RelLayoutTest;
    
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.Bundle;
    import android.widget.ImageView;
    
    public class RelLayoutTestActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
                    R.drawable.icon);
            bitmap = Bitmap.createScaledBitmap(bitmap, 18, 18, true);
    
            ImageView imageView = (ImageView) findViewById(R.id.imageView1);
            imageView.setImageBitmap(bitmap);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My PHP code below shows an image on browser as its original size 300x300.
I'm trying to write some code that deletes an image off the hard-disk once
Is there any maximum size for code in Java? I wrote a function with
i have this CSS code: h1 { font-size:22px; color:#341C12; font-weight:normal; font-style:italic; } .h1color h1{
The code below is extremely slow for tables of any significant size. (100, 1000,
I have some C++ code that prints a size_t : size_t a; printf(%lu, a);
i create css code like .inputHide { font-size : 100px; width : 100px; height
In this code, for vector size, n >=32767, it gives segmentation fault, but upto
My code is -(UIImage *)addText:(UIImage *)img text:(NSString *)text1 { int w = img.size.width; int
I'm trying to create an image with some text on it and I want

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.