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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:14:42+00:00 2026-06-09T22:14:42+00:00

I know that in XML, Views are expensive, and ideally you should strive for

  • 0

I know that in XML, Views are expensive, and ideally you should strive for as little as possible. But in my case, I am designing my layout in a such a way that I am sort of forced to have a lot of Views, close to 80. Eclipse gave me a warning on this, so I deleted some Views, but I can only do so much as my implementation requires minimum, 48 Views off the bat, and not including some extra stuff. So my question is in whether I should really find a simpler way, or if its fine. What is the actual number that really should be maximum?

XML file


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView 
        android:id="@+id/top_bar_date_display"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="July 1, 2012"
        android:background="#696969"/>
<ScrollView 
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    >
<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/day_view_floaty_holder"
    android:background="#000000">
    <GridLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnCount="1" >

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >
            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="12\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal"
                android:layout_marginBottom="1dp" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="1\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>
        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="2\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="3\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="4\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="5\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="6\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="7\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="8\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="9\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView 
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="10\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="11\nAM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >
            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="12\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="1\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="2\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="3\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="4\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="5\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="6\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="7\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="8\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="9\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="10\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="vertical"
            android:background="#ffffff"
            android:layout_marginBottom="1dp" >

            <TextView
                android:layout_width="20dp"
                android:layout_height="60dp"
                android:text="11\nPM"
                android:background="#bebebe"
                android:textSize="10dp"
                android:gravity="center_horizontal" />
        </LinearLayout>

    </GridLayout>

    <!-- THIS GRIDLAYOUT IS WHERE THE EVENTS WILL BE PLACED-->
    <GridLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnCount="1" >
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_0"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_1"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_2"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_3"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_4"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_5"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_6"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_7"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_8"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_9"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_10"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_11"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_12"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_13"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_14"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_15"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_16"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_17"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_18"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_19"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_20"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_21"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_22"
            android:orientation="horizontal" ></LinearLayout>
        <LinearLayout 
            android:layout_height="61dp"
            android:layout_width="match_parent"
            android:layout_marginLeft="20dp"
            android:id="@+id/day_view_23"
            android:orientation="horizontal" ></LinearLayout>

    </GridLayout>


</RelativeLayout>
</ScrollView>


I should probably explain the logic behind what the code translated to. I essentially needed a GridLayout of 24 rows, as well as another GridLayout of another 24 rows floated above it. I did this to separate what I need to float above the first GridLayout. Its suppose to be for a Day View for a calendar app.

  • 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-09T22:14:44+00:00Added an answer on June 9, 2026 at 10:14 pm

    As I said I would use a ListView to show the data to avoid making so much views. First I would create a class to represent the user events that you show in the list:

    private static class Event {
    
            public int startHour;
            public int hours = 1;
            public String name;
            public String date;
            public boolean isEmptyEvent = true;
    
            public Event(int startHour, int hours, String name, String date,
                    boolean isEmptyEvent) {
                this.startHour = startHour; 0 to 23 (the method getStartHour makes this pretty)
                this.hours = hours; // how many this event requires(default 1)
                this.name = name;
                this.date = date;
                this.isEmptyEvent = isEmptyEvent;
            }
    
            public String getStartHour() {
                // should optimize this method so you don't end up creating String
                // after String(char array?)!
                if (startHour < 10) {
                    return "0" + startHour + ":00";
                }
                return String.valueOf(startHour) + ":00";
            }
        }
    

    Then I would parse the data I have in Events object(I don’t know what you save in the database so this is just guessing):

    public SparseArray<Event> getData(String date) {
            // here you get the data from the database and create Events object for
            // those dates
            SparseArray<Event> data = new SparseArray<Event>(); // for efficiency
                    // add some random events
            data.put(3, new Event(3, 1, "Breackfast", date, false));// one event at 3 taking 1 hour
            data.put(14, new Event(14, 3, "Lunch", date, false));// one event at 14 taking 3 hour
            data.put(20, new Event(20, 2, "Dinner", date, false));// one event at 20 taking 2 hour
            return data;
        }
    

    Then in the adapter I would fill the rest of the empty entries(where the user didn’t yet set anything) with empty Events objects and show it to the user. As the code is a little big I will not post it here , instead you can find the full activity+ layouts here https://gist.github.com/3370107

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

Sidebar

Related Questions

I know that wordpress can be exported in the form of XML, but there
I know that we can design the layout in *.xml then in the action
i know that it's possible to declare a dummy element in an XML, for
I know that soap can send XML over http, is there any way to
HI, i need a XML parser. i want to know that which one is
Does anybody know a Perl library that can parse XML documents and enables me
Could someone know where is saved path to external XML-File that contain configuration for
It has been suggested that I use CSS for displaying XML. I know in
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still

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.