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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:58:13+00:00 2026-05-24T01:58:13+00:00

(note that I’m a total beginner in android programming) I have a class that

  • 0

(note that I’m a total beginner in android programming)

I have a class that derives from GLSurfaceView.

What I would like is to place some views (image,text) on top of it.
I managed to get the text view to position properly by using textView.setPadding(300,0,0,0);

The problem is that I cannot get the image view to position properly. I’ve tried imageView.layout(), imageView.setPadding().

Here is the code:

 ImageView imageView=new .... // Create and set drawable

 // Setting size works as expected
 RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(200,200);
 imageView.setLayoutParams(lp);

 surfaceView = new MySurfaceViewDerivedFromOpenGLSurface(...);

 setContentView(surfaceView);

 addContentView(textView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
 addContentView(textView2, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
 addContentView(imageView, lp); // Add the image view

Is it even possible to position it properly this way without specifing the stuff in the XML file?

I saw an example in the sdk dev website that shows how to create views on the openGL surface view, but the problem is that I have a derived class and I don’t know if I can specify it in the XML file (I have 0% experience in the XML, Eclipse handled everything for me so far).

  • 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-24T01:58:14+00:00Added an answer on May 24, 2026 at 1:58 am

    You’ll save a ton of headaches later by learning how to use xml layout. Specifying a layout for a custom view tripped me up too. This is how it works:

    <view class="complete.package.name.goes.here.ClassName"
        android:id="@+id/workspace"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >        
    </view>
    

    So a really simple vertical layout for your app would be:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    
        <TextView android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        <TextView android:id="@+id/textView2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        <ImageView android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    
        <view class="package.name.to.MySurfaceViewDerivedFromOpenGLSurface"
            android:id="@+id/mySurfaceView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1">        
        </view>     
    </LinearLayout>
    

    You can get a reference to anything in your layout files as long as there’s an id:

    ImageView myImageView = (ImageView ) findViewById(R.id.imageView1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please note that I'm a complete beginner to Qt development. I have a QWebView
Warning: Note that this is a dumb question of something that I would probably
[Please note that this is a different question from the already answered How to
(Please note that I have seen a similar question on StackOverflow recently, however I
Note that this is a follow-up question from my previous one: How to memorize
Note that my activity is NOT extending ListActivity; just Activity. I have a list
(Note that I've searched online for the warnings I'm describing below, and have come
The javadoc says: Please note that this class is designed to provide convenience rather
Note that the following code is in a class a single class private string
*(note that everything works perfectly outside of the Ajax. the submittable class works to

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.