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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:04:32+00:00 2026-06-11T14:04:32+00:00

I am trying to create a layout dynamically and I am having a small

  • 0

I am trying to create a layout dynamically and I am having a small issue. For some reason I just cant figure out how to set the ImageViews weight. I looked up this on a tutorial site but when I try to use it I get an error:

LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1);

What I am trying to accomplish is this (From the Outline perspective):

–LinearLayout (Horizontal) (LL1)

——ImageView (IV1)

——LinearLayout(Vertical) (LL2)

Code that I am trying to accomplish in XML:

        <LinearLayout
        android:id="@+id/skillOneAbility"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/skillOneImage"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"/>


        <LinearLayout
            android:id="@+id/skillOneAbilityInfo"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="5"
            android:orientation="vertical" >

This is the code I have so far but I am not sure how to set the weight of the ImageView:

 private LinearLayout createInnerHorizontalLayout1() {
    LinearLayout mainLayout = new LinearLayout(getActivity());
    mainLayout.setOrientation(LinearLayout.HORIZONTAL);
    mainLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    //Create the image view and the linear layout with text views
    ImageView iView = new ImageView(getActivity());
    iView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT));

    LinearLayout myInnerVerticalLayout = createInnerVerticalLayout();
}

How would I accomplish that XML that I linked up top?

  • 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-11T14:04:33+00:00Added an answer on June 11, 2026 at 2:04 pm
    LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, .60f); 
    

    the last parameter is the weight (a float), and having LinearLayout.LayoutParams will fix the error you have with importing the wrong layoutparams

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

Sidebar

Related Questions

I am trying to just create a basic layout, but i am having trouble
In my activity I create 5 tabs dynamically. I'm trying to figure out why
I am trying to build a layout dynamically which display some text and image
I'm trying to create a buttons dynamically and add them to table layout panel
I'm having an issue in my application. I wish to dynamically create several tabbed
I'm trying to dynamically create some table rows, but on the Table Row I
I'm trying to dynamically create some CheckBoxes in one of my Android activities, but
I am trying to figure out how to load different groupviews dynamically. I am
Im trying to create a layout in flex using mxml, the layout contains a
I'm trying to create a layout like so: On the left hand side I

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.