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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:22:30+00:00 2026-06-02T07:22:30+00:00

I’m creating a car dock application for myself and I have 6 buttons to

  • 0

I’m creating a car dock application for myself and I have 6 buttons to allow me to place shortcuts to applications. I’ve designed a layout for landscape and portrait mode. I’m having issues with screen sizes in portrait mode. I have my icons lined up like so:

Text up here
------------
| 1  |  2  |
------------
| 3  |  4  |
------------
| 5  |  6  |
------------

Here’s the XML for the buttons:

<Button
    android:id="@+id/btnLaunchSlotOne"
    style="@style/launchButton"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_weight="1"
    android:layout_marginRight="8dp"
    android:padding="10dp"
    android:text="Navigation"
    android:textColor="#ffffff" />

Now the problem I’m having is when I test the app on a smaller screen size, the buttons don’t seem to resize and they go off the screen at the bottom. How can I get them to scale properly? I thought using “dp” took care of all that?

Do I need to calculate the screen size programatically?

Thanks for the suggestions / help!

  • 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-02T07:22:34+00:00Added an answer on June 2, 2026 at 7:22 am

    Use something like the layout below to correctly nest the buttons:

    <LinearLayout
        android:orientation="vertical">
        <TextView>Put your Text here</TextView>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_weightSum="2">
            <LinearLayout
                android:orientation="vertical"
                android:layout_height="fill_parent"
                android:layout_width="0dp"
                android:layout_weightSum="3"
                android:layout_weight="1">
                <Button 
                    android:layout_weight="1"/>
                <Button 
                    android:layout_weight="1"/>
                <Button 
                    android:layout_weight="1"/>
            </LinearLayout>
            <LinearLayout
                android:orientation="vertical"
                android:layout_weightSum="3"
                android:layout_height="fill_parent"
                android:layout_width="0dp"
                android:layout_weight="1">
                <Button 
                    android:layout_weight="1"/>
                <Button 
                    android:layout_weight="1"/>
                <Button 
                    android:layout_weight="1"/>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
    

    Then each button needs height of 0dp (this lets the weight apply and scale the button horizontally) and width of fill parent.

    The trick is that the weight of a child element will cause the dimension that is set to 0dp to fill to a percentage of of the weightSum of the parent element.

    Eg i have a linear layout with weightSum 3 and 3 child buttons of weight 1. When height is set to 0dp they will each take 1/3 of the height of the parent as their height. When width is set to 0dp they will each take 1/3 of the width of the parent as their own.

    This is the best way to organise items according to a percentage width or height.

    As an aside if you had two buttons one with weight 2 and one with weight 1 then 1 button would be 33% of the parents height/width and the other 66% of the parents height/width. Handy little trick and works on all screens.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.