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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:18:39+00:00 2026-06-10T11:18:39+00:00

i am working on android api8. i want to position/place a view on screen

  • 0

i am working on android api8.
i want to position/place a view on screen dynamically.
but to use setX and setY we need API level 11 and above.
how can we use it in API 8 or is there any alternative for this?
need 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-10T11:18:40+00:00Added an answer on June 10, 2026 at 11:18 am

    You can do this by using the LayoutParams.
    These can be added to components of the android interface to set their bounds and position.

    An example (setting the LayoutParams on a child view of a RelativeLayout)

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); //The WRAP_CONTENT parameters can be replaced by an absolute width and height or the FILL_PARENT option)
    params.leftMargin = 50; //Your X coordinate
    params.topMargin = 60; //Your Y coordinate
    childView.setLayoutParams(params);
    

    Take note that the type of the LayoutParams must be equal to the parent of the childview you want to add them to. (LinearLayout.LayoutParams for a LinearLayout , RelativeLayout.LayoutParams for a RelativeLayout etc.).

    Also, instead of childView.setLayoutParams(params); you can also use parentView.addView(childView,params); to set the Layoutparams when the item is added to the parent container.

    NOTE! The values for the coordinates are in pixels. Since it’s best practice to use DP values to define your interface sizes you could use this piece of code to convert dp to pixels:

    private int getPixels(int dipValue){ 
         Resources r = getResources();
         int px = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue,   r.getDisplayMetrics());
         return px; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working Android tuner project app that I want to use as
I am working with android application where I want play audiobooks from current position
I am currently working on android project where I want to have a text
I'm working with Android and I really need a fast way to get a
I am working on android apps. I want to add a contact in android
I am working on Android 2.1 with API v7 . How can I implement
I'm working on android unity3d project where I want to post some stuff to
I'm working on Android, but this is a java question. I have an image
I am working on Android database type application. We need to show some reports.
I am working in android. I want to show simple google map in my

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.