why do my view overlay all other activity elements ?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

why do my view overlay all other activity elements ?

Postby aneuryzma » Mon Jan 18, 2010 10:18 am

hi,

I'm programmatically adding a view to a LinearLayout element but, the view is overlaying any other element in my activity.

I was wondering how to fit my new view in the empty space, instead.... The parent is: dragLayout

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.         android:id="@+id/dragAreaLayout" android:layout_width="fill_parent"
  4.  
  5.         android:layout_height="fill_parent" android:orientation="vertical">
  6.  
  7.  
  8.  
  9.  
  10.  
  11.         <LinearLayout android:id="@+id/dragLayout"
  12.  
  13.                 android:layout_width="fill_parent"
  14.  
  15.                 android:layout_height="wrap_content"
  16.  
  17.                 android:orientation="vertical">
  18.  
  19.         </LinearLayout>
  20.  
  21.        
  22.  
  23.        
  24.  
  25.                 <EditText android:id="@+id/inputTagBox"
  26.  
  27.                         android:layout_width="fill_parent"
  28.  
  29.                         android:layout_height="wrap_content">
  30.  
  31.                 </EditText>
  32.  
  33.                
  34.  
  35.                 <Button android:text="Send tag" android:id="@+id/ButtonSendTag"
  36.  
  37.                         android:layout_width="fill_parent" android:textSize="20px"
  38.  
  39.                         android:layout_height="wrap_content">
  40.  
  41.                 </Button>
  42.  
  43.  
  44.  
  45. </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


This is the code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.dragarealayout);
  2.  
  3.                
  4.  
  5.                 LinearLayout dragLayout = (LinearLayout) this.findViewById(R.id.dragLayout);
  6.  
  7.                 dragLayout.setOnTouchListener((OnTouchListener) this);
  8.  
  9.                 dragLayout.addView(new DrawableView(this));
  10.  
  11.  
  12.  
  13. ...
  14.  
  15.  
  16.  
  17. public class DrawableView extends View {
  18.  
  19.  
  20.  
  21.                 public DrawableView(Context context)
  22.  
  23.                 {
  24.  
  25.                         super(context);
  26.  
  27.  
  28.  
  29.                 }
  30.  
  31.  
  32.  
  33.                 protected void onDraw(Canvas canvas)
  34.  
  35.                 {
  36.  
  37.                         Paint p = new Paint();
  38.  
  39.                         p.setColor(Color.RED);
  40.  
  41.                         p.setStyle(Paint.Style.STROKE);
  42.  
  43.                        
  44.  
  45.  
  46.  
  47.                         canvas.drawRect(downX, downY, x , y, p);
  48.  
  49.                         invalidate();
  50.  
  51.                 }
  52.  
  53.  
  54.  
  55.         }
  56.  
  57.  
  58.  
  59.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
aneuryzma
Developer
Developer
 
Posts: 28
Joined: Wed Jan 06, 2010 10:46 am

Top

Postby aneuryzma » Mon Jan 18, 2010 10:39 am

I've also tried to pass these parameters to addView

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. dragLayout.addView(new DrawableView(this), new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. dragLayout.addView(new DrawableView(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Parsed in 0.034 seconds, using GeSHi 1.0.8.4



but it is the same

thanks
aneuryzma
Developer
Developer
 
Posts: 28
Joined: Wed Jan 06, 2010 10:46 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 4 guests