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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:05:55+00:00 2026-05-30T02:05:55+00:00

I want to design a simple interface for a calculator. The calculator has 2

  • 0

I want to design a simple interface for a calculator. The calculator has 2 group of keys, the basic keys and the extra keys. I want to put the extra keys on a HorizontalScrollView. Here is the xml file:

<HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="A" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="B" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="C" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="D" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="E" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="F" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="G" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="H" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="I" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="J" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="K" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="L" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="M" />
        </LinearLayout>
    </HorizontalScrollView>

Here is how it looks like:

enter image description here

However, it works very well and I can scroll horizontally and click on any button I want. But I want to customize it more. So here is my questions:

  • How can I edit the width of each button so that only 5 buttons can be displayed on the screen at a time.
  • How can I make the scrolling by 5 buttons offset, i.e if I have the leftmost 5 buttons appear on the screen and I scroll to the right, those 5 buttons will be gone to the left and the next 5 buttons will be shown.
  • How to disappear the scrollbar (i.e scrolling with invisible scrollbar).

Thank you 🙂

  • 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-30T02:05:56+00:00Added an answer on May 30, 2026 at 2:05 am

    if you add android:weightsum="5" to your linearlayout and then add android:layout_weight="1" to each of the buttons I think it will put 5 of them on the screen at a time. However I am not very good at using the weight attribute, anytime I use it I end up with a bunch of guess and check, however my gut tells me that it is possible to achieve what you are after with weight and weightsum somehow.

    However, I do wonder does it make sense to always show 5 buttons no matter what screen you are on? To me it seems like you may want to vary it at least some so that maybe the smallest of screens only get 4 buttons, and the widest of screens might get 6, otherwise you are going to end up with a very wide range of button sizes across all of the different device densities.

    add this to your HorizontalScrollView:

    android:scrollbars="false"
    

    that should take care of the scroll bar for you.

    As for the part about scrolling 5 at a time, Im afraid to implement this you might have to manually handle it with the horizontalScrollView.smoothScrollBy() method, you’ll have to make it do the calculations to figure out how far it needs to go in order to pass 5 buttons. Then override your onTouch listener to make the smoothScrollBy() call for you.

    smoothScrollBy() – its worth looking at smoothScrollTo() also.

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

Sidebar

Related Questions

We want to design a simple domain specific language for writing test scripts to
I just want to design this very simple website. Basically there are multiple pages
That's my question, I want design all the interface of my application within an
So I'm having trouble with a simple RTS design. Basically I want to have
I want design my startup screen with progress bar. But I don't how to
I want to design a web page with a banner and an iframe. I
I want to design a c# program which can run program a 3rd exe
Say I want to design a database for a community site with blogs, photos,
I am new to this. I want to design an image gallery in my
How do I send an SMS to Active Directory Users. I want to design

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.