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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:29:59+00:00 2026-06-17T04:29:59+00:00

I do have a view, which looks like this atm: I want that first

  • 0

I do have a view, which looks like this atm:

enter image description here

I want that first 3 black rows to fill out ~70% of screen. Doesnt matter what will be the screen size. I thought i can achieve it by assigning weights to Layouts, seems it is not so easy. As you can see I have achieved it with buttons, they are always stretch to width.

So, here is my code for this xml:

 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"        
    android:orientation="vertical" 
    android:id="@+id/main"
    android:weightSum="10" //mean summary 100%

    > 
<LinearLayout
    android:id="@+id/lin1"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:orientation="horizontal"
    android:weightSum="3"    
    android:layout_weight="2.3"   //23% for each row 
     >
    <Button
        android:id="@+id/button1"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_marginRight="2dp"
        android:layout_weight="1" 
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Layout Normal" />

    <Button
        android:id="@+id/button2"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_marginRight="2dp"
       android:layout_weight="1" 
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1" 
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad3" />
</LinearLayout>

<LinearLayout
    android:id="@+id/lin2"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_marginTop="2dp"
    android:orientation="horizontal"
    android:weightSum="3" 
    android:layout_weight="2.3" >

    <Button
        android:id="@+id/button4"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_marginRight="2dp"
        android:layout_weight="1"
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad4" />

    <Button
        android:id="@+id/button5"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_marginRight="2dp"
        android:layout_weight="1"
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad5" />

    <Button
        android:id="@+id/button6"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad6" />
</LinearLayout>



<LinearLayout
    android:id="@+id/lin3"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_below="@id/lin2"
    android:orientation="horizontal"
    android:weightSum="3"
    android:layout_weight="2.3"  >

    <Button
        android:id="@+id/button7"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_marginRight="2dp"
        android:layout_weight="1"
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad7" />


    <Button
        android:id="@+id/button8"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_marginRight="2dp"
        android:layout_weight="1"
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad8" />

    <Button
        android:id="@+id/button9"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/greenbtn"
        android:onClick="onClick"
        android:text="Pad9" />
</LinearLayout>

    <LinearLayout
    android:id="@+id/lin5"
    android:layout_width="fill_parent"
    android:layout_below="@id/lin3"
    android:layout_height="60dp"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal"
    android:layout_weight="2.1"  > //21% for toggles

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:onClick="onClick"
        android:textOff="Loop1 Off"
        android:textOn="Loop1 ON" />

    <ToggleButton
        android:id="@+id/toggleButton2"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:onClick="onClick"
        android:textOff="Loop2 Off"
        android:textOn="Loop2 ON" />

    <ToggleButton
        android:id="@+id/toggleButton3"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:onClick="onClick"
        android:textOff="Loop3 Off"
        android:textOn="Loop3 ON" />

    <ToggleButton
        android:id="@+id/toggleButton4"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:onClick="onClick"
        android:textOff="Loop4 Off"
        android:textOn="Loop4 ON" />
</LinearLayout>


<LinearLayout
    android:id="@+id/lin6"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
     android:layout_weight="1"       //10% for webview
     >

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="50dp"

    />
</LinearLayout>
</LinearLayout>

As you can see, in my idea, I have gave to each black row 23% of screen(23×3=69%), for toggles 21%, and for webview 10%.

Any help would be much 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-17T04:30:01+00:00Added an answer on June 17, 2026 at 4:30 am

    @Daler you’re trying to balance the heights using weight, so you must set the layout_height to 0dp

    also, it seems to me that you’re using way too many LinearLayouts, maybe you can eliminate a few to save in memory, processing time, responsiveness. Something like that I guess:

    <Linear Layout - vertical - match_parent >
    
       // 0.269 * 3 = 0.7
       <linear layout 1 - horizontal weight = 0.269 layout_height=0dp> the three views </>
       <linear layout 2 - horizontal weight = 0.269 layout_height=0dp> the three views </>
       <linear layout 3 - horizontal weight = 0.269 layout_height=0dp> the three views </>
        // the other 30%
       <linear layout 4 - horizontal weight = 0.15 layout_height=0dp> the three views </>
       <linear layout 5 - horizontal weight = 0.15 layout_height=0dp> the three views </>
    
    
    </end the top linear layout>
    

    that is assuming that it’s 3 rows on the black area that should be 70%. That’s what I understood from your image.

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

Sidebar

Related Questions

I have a view which I would like to fill up the entire screen
i have view which looks something like this : <% using (Ajax.BeginForm(new AjaxOptions {
I have an array in Knockout view model which looks like so: this.Activities =
I have a view which looks like this value1count value2count value3count ---------------------------------------- 25 35
Here goes: I have a view that looks like this: public interface IAddressView {
I have implemented a custom list view which looks like the twitter timeline. adapter
I have a custom cell which looks like this Cell -ContainingView (called cellframe) --Label
I have an observer which looks like this: class CommentObserver < ActiveRecord::Observer include ActionView::Helpers::UrlHelper
I have custom UIViewController which looks like this. @implementation UIViewControllerCustom - (id)init { self
HI all i have a json data which looks like this [ Data:[ {Id:1

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.