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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:10:56+00:00 2026-06-04T13:10:56+00:00

I was thinking about how to implement an ImageView that shows an image and

  • 0

I was thinking about how to implement an ImageView that shows an image and while I’m refreshing its content with a new image it shows a “Loading…” text with a circular ProgressBar on the right, so I’ve written the code attached below.. Is this the correct way to implement what I want? Does the LinearLayout with TextView and ProgressBar consume zero resources when it’s visibility is set to GONE? Does the ProgressBar itself consume zero resources (I’m thinking about the progress looping circle animation) when itself or it’s parent layout’s visibility is set to GONE? If I’d set it to INVISIBLE it should consume a bit of resources due to Layout management, but it still should not consume resources for animating the progress circle, right?

EDIT: when I’ve said “does it consumes resources” above, I meant CPU resources, since it obviously consumes a bit of memory resources since I do not release the view when I simply set its visibility to GONE. I’ve added this comment after the first comment and the first answer.

I hope the code below is correct, in case some other newbie like me is wondering how to implement the same thing.

Follows the code and an image showing the result on an emulator:

enter image description here

main.xml

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/image_view1"
            android:src="@drawable/fish"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:contentDescription="image view 1" />


       <LinearLayout
           android:id="@+id/layout_progress"
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_gravity="center_vertical"
           android:background="@drawable/filled_rectangle"
           android:gravity="center_vertical|center_horizontal"
           android:orientation="horizontal"
           android:visibility="gone" >

           <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:gravity="fill_horizontal"
               android:text="Loading..."  
               android:textSize="30sp" 
               android:layout_gravity="center_vertical"/>

               <!-- style="@android:style/Widget.ProgressBar.Small" --> 
           <ProgressBar
               android:id="@+id/progress_bar1"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_gravity="center_vertical"
               android:indeterminateOnly="true"/>

       </LinearLayout>
   </FrameLayout>

   <Button
       android:id="@+id/refresh_image"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center_horizontal"
       android:onClick="onClick" 
       android:text="@string/refresh_image"/>

</LinearLayout>

drawables/filled_rectangle.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#80000000"/>
</shape>

TestFrameLayoutActivity.java

public class TestFrameLayoutActivity extends Activity {
    private int progressVisible;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LinearLayout layout = (LinearLayout) findViewById(R.id.layout_progress);
        progressVisible = (layout.getVisibility() == View.VISIBLE)?1:0;
    }

    public void onClick (View view) {
        progressVisible = 1 - progressVisible;
        LinearLayout layout = (LinearLayout) findViewById(R.id.layout_progress);
        ImageView img = (ImageView) findViewById(R.id.image_view1);

        if (progressVisible == 1) {
            layout.setVisibility(ProgressBar.VISIBLE);
        } else {
            layout.setVisibility(ProgressBar.GONE);
        }
    }
}
  • 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-04T13:10:57+00:00Added an answer on June 4, 2026 at 1:10 pm

    No. It is GONE in terms of what is shown on the screen, but it still has a memory mapping in R.java, and it is available to the View.

    If you created a View with several billion GONE children, it would likely crash as a result of memory running out.

    That said, It does consume less resources because it does not need to call onMeasure() or onDraw().

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

Sidebar

Related Questions

I was thinking about how to implement a process that gives the number of
While thinking about the way to implement Scheme R5RS, I have become puzzled about
I'm thinking about using the java application object to implement a simple cache, to
Thinking about avoiding code replication, I got a question that catches me every time
Just thinking about the best way to build an Order form that would (from
I was thinking about a code that I wrote a few years ago in
I am about to implement a worker thread with work item queuing, and while
I've been thinking about using shared pointers, and I know how to implement one
I was thinking about moving from ASMX to WCF to implement web services. One
Recently I've been thinking about finite state machines (FSMs), and how I would implement

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.