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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:08:51+00:00 2026-06-07T18:08:51+00:00

I have next view hiererchy: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content android:paddingLeft=10dp android:paddingRight=10dp android:gravity=center> <LinearLayout android:layout_width=fill_parent

  • 0

I have next view hiererchy:

     <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:gravity="center">
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/group_bg"
            android:gravity="center_vertical" 
            android:baselineAligned="false">
            <LinearLayout
                android:id="@+id/itemplace"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dp"
                android:layout_weight="1" >
                <include
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    layout="@layout/pin" />
            </LinearLayout>
            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/arrow_black"/>
        </LinearLayout>
    </LinearLayout>

I need to get itemplace width before this hierarchy will be drawing. I can not use OnLayoutChangeListener because I use API level 7.

I know that I must use measure() and layout() methods to calculate size of my views but I dont know hot it to do.

Root view in my hierarchy must fill all width of screen, so itemplace width depended of parent size, parent paddings and FrameLayout width.

What must I do to get it width?

  • 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-07T18:08:54+00:00Added an answer on June 7, 2026 at 6:08 pm

    I have find out way to get view width. I can get it after android measuret it but before drawing using OnPreDrawListener in ViewTreeObserver:

        view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener()
        {
            @Override
            public boolean onPreDraw()
            {
                int avaliableWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
    
                Log.d("width", String.valueOf(avaliableWidth));
    
                return true;
            }
        });
    

    From Android documentation:

    Callback method to be invoked when the view tree is about to be drawn.
    At this point, all views in the tree have been measured and given a
    frame. Clients can use this to adjust their scroll bounds or even to
    request a new layout before drawing occurs.

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

Sidebar

Related Questions

I have next problem: i have a View: <UserControl x:Class=WpfApplication1.UserControl1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008
I have a next code in my view: <% @todos.each do |todo| %> <tr>
I have a view that I would like to populate data when the next
So I have this UINavigationController, I'm on the first moving to the next view,
In examples I have seen of UINavigationContoller and UITableView , switching to next view
I have a tableView (first view) and the detailView (next view) containing the details
I have the next code of view: @{ Layout = null; } @Html.Raw(ViewBag.ReportHeader as
I have problems entering a next view in the TableViewController. When I click on
In my view i have ImageView.If i click ,it should open nextview. Please help
I have next tables Order , Transaction , Payment . Class Order has some

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.