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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:24:26+00:00 2026-06-13T03:24:26+00:00

I have a layout as shown below. It is inflated by code and added

  • 0

I have a layout as shown below. It is inflated by code and added to a HorizontalScrollView, sometimes a few hundred times, and causing getting memory issues.

I’m wondering if there’s anything that can be done to make it more efficient? Originally I used LinearLayouts, and replacing that with RelativeLayout made a huge difference to the scrolling. Now I’m wondering if it can be further improved?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="156dp"
    android:layout_height="254dp"
    android:paddingLeft="7dip"
    android:paddingRight="7dip">

    <FrameLayout android:id="@+id/button_frame"
    android:layout_width="156dp"
    android:layout_height="218dp">

    <ImageView android:id="@+id/button_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/image_bg"
        />

        <ImageView android:id="@+id/button_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom|right"
        />

        <TextView android:id="@+id/button_select"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="2dip"
        android:background="@drawable/btn_selector_bg_selected"
        />

        <TextView android:id="@+id/button_selected"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="2dip"
        android:background="@drawable/title_bg_selected"/>

    </FrameLayout>

    <TextView
    android:id="@+id/button_title"
    android:layout_width="156dp"
    android:layout_height="36dp"
    android:textColor="#ffffff"
    android:singleLine="true"
    android:textSize="13sp"
    android:textStyle="bold"
    android:gravity="center_vertical|left"
    android:ellipsize="end"
    android:paddingLeft="30dip"
    android:paddingRight="5dip"
    android:layout_below="@id/button_frame"
    android:background="@drawable/title_bg"/>

</RelativeLayout>

The ImageView button_image is populated using AQuery image caching, so I’m not sure if there’s much more I can do to improve the way the image is handled. But any tips on improvements greatly 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-06-13T03:24:27+00:00Added an answer on June 13, 2026 at 3:24 am

    In general, a good way to optimize layouts in Android is to minimize the amount of nesting of containers within each other. The deeper you nest layout containers, the more work the framework must do to measure, layout, and process events for the view hierarchy.

    But I think you may be asking the wrong question.

    The HorizontalScrollView and VerticalScollView are not intended for the use you’re putting them to. They’re meant to hold a mostly static layout, and allow it to scroll if necessary depending upon the size of the screen it happens to be running on.

    You want a repetitive list of mostly identical Views, that the user can scroll. The correct Android view container to use is ListView, or one of the other descendants of AdapterView.

    ListView is careful only to create/inflate the necessary child views to fill the space on screen, and reuse them as the user scrolls. This solves the memory problems you’re experiencing. It does that by requiring you to pair it up with an Adapter – an object that wraps the actual data being displayed, and creates on-demand the correct view for a given data item.

    Since you’re trying to do horizontal scrolling, you might also look at Gallery (now deprecated in Android) or the newer ViewPager class, both of which support horizontal movement through a large list of data.

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

Sidebar

Related Questions

Currently I have a borderContainer layout as shown below: My code for this layout
I have a custom Layout shown below and I would like to update the
I have 1 ListView and 2 buttons in layout.xml file as shown below: <ListView
I have two buttons in my xml layout as shown bellow. I used an
I have designed the following custom layout to be inflated into a DialogFragment then
I'm trying to build the liquid layout shown below in CSS. The left column
I have a datagrid, populated as shown below. When the user clicks on a
I want to make a table layout as shown in the below screen: I
I have something like the following (shown below) defined in my styles.xml file. But
I have _Layout.cshtml defined for my mvc application, which is shown below: @inherits System.Web.Mvc.WebViewPage

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.