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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:51:06+00:00 2026-05-25T19:51:06+00:00

I’ve been trying to successfully align the views so they look the same on

  • 0

I’ve been trying to successfully align the views so they look the same on other phones but I can’t succeed. I just can’t get it to work. Here is the background:

enter image description here

I want a TextView in the middle of the green zone, and in the middle of the blue zone, and an imageview in the orange zone. I already asked this and I got a suggestion to use layout_weight here. But I can’t correctly calculate the weight. How can I do this? Is the layout_weight is the right way to go? how do I calculate it?

The measures:
The left and right side of the screen (yellow) are empty.. 40 px each..
The green zone have a TextView at the centrer .. 236 px
The orange zone has an imageview at the center .. 44 px
The blue zone has a TextView at the center .. 120 px

The xml I used for the custom_row:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="horizontal"
android:layout_height="wrap_content"  android:paddingTop="10dip" android:paddingBottom="10dip">

<TextView android:id="@+id/Start_Numbering" android:textSize="19.5dip"
    android:layout_width="0dp" android:layout_height="wrap_content"
    android:layout_weight="0.3" android:background="@drawable/list_number_bg"
    android:gravity="center"
    />

<ImageView android:id="@+id/Start_ImageView"
    android:layout_weight="0.1" android:layout_height="fill_parent" android:scaleType="center" 
    android:layout_width="0dp" android:src="@drawable/list_noaudioavailable"
    android:gravity="center"
    ></ImageView>


<TextView android:id="@+id/Start_Name" android:textColor="#a7e9fe"
    android:textSize="25dip" android:layout_width="0dp"
    android:layout_weight="0.6"
    android:gravity="center"  android:background="@drawable/list_name_bg"
    android:layout_height="wrap_content" />

  • 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-25T19:51:07+00:00Added an answer on May 25, 2026 at 7:51 pm

    If you want your layout to be flexible for different screen sizes then you DON’T want to hard code pixel widths instead you should use layout_weights as was the answer in your previous question. For a ViewGroup you can define a total weightSum and then the individual weights must be defined for each of the children which must add up to the weightSum of the parent. Here is a simple example that is similar to what you described above using black and white colors:

    <LinearLayout android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="20"> 
            <View android:id="@+id/view1" 
                android:layout_weight="2"
                android:layout_width="0dp" 
                android:layout_height="fill_parent"
                android:background="@android:color/white"/>
    
            <View android:id="@+id/view2" 
                android:layout_weight="7"
                android:layout_width="0dp" 
                android:layout_height="fill_parent"
                android:background="@android:color/black"/>
    
            <View android:id="@+id/view3" 
                android:layout_weight="2"
                android:layout_width="0dp" 
                android:layout_height="fill_parent"
                android:background="@android:color/white"/> 
    
            <View android:id="@+id/view4" 
                android:layout_weight="7"
                android:layout_width="0dp" 
                android:layout_height="fill_parent"
                android:background="@android:color/black"/>
    
            <View android:id="@+id/view5" 
                android:layout_weight="2"
                android:layout_width="0dp" 
                android:layout_height="fill_parent"
                android:background="@android:color/white"/>
    
    </LinearLayout>
    
    The measures:
    The left and right side of the screen (yellow) are empty.. 40 px each..
    The green zone have a TextView at the centrer .. 236 px
    The orange zone has an imageview at the center .. 44 px
    The blue zone has a TextView at the center .. 120 px
    

    just convert those pixels vales into width valuse and use the sum of those pixels values as the weightSum in the parent

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I'm looking for suggestions for debugging... If you view this site in Firefox or

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.