• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Two Views On Top of Each Other Using XML

I want to display two views on a screen. One is a randomly positioned dot bitmaps. I can get that do display with setContentView(...).
I also have two bitmaps and a textview that are arranged via xml layout language and then using setContentView(R.layout.activity_title);


________________________________________
**DrawV.java**
!!!BASICALLY I THINK I HAVE TWO setContentViews(...) THAT I WANT TO DISPLAY AT THE SAME TIME. TELL ME IF YOU WANT MORE INFORMATION.
________________________________________
[HIGH]public class DrawV extends View {
VARIABES...

public DrawV(Context context) {
CREATE CIRCLES (CIRCLE OBJECTS) STORING COORDINATES RANDOMLY CHOSEN...

@Override
protected void onDraw(Canvas canvas) {
DRAW THESE CIRCLES AS BITMAPS...SCREEN IS NOW RANDOMLY COVERED WITH MANY DOTS
}

[/HIGH]
_______________________________________
**GameActivity.java**
_______________________________________
[HIGH]public class GameActivity extends Activity {
private DrawV drawView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

drawView = new DrawV(this);
setContentView(R.layout.activity_title); !!!SHOWS LAYOUT (HOPEFULLY TEXTVIEW, TWO BUTTONS, AND RANDOMLY POSITIONED DOTS (DOTS NEVER WORKS) WHICH IS OVERDONE BY DRAWVIEW...
setContentView(drawView); !!!IF THIS STATEMENT IS SECOND IT RENDERS INTEAD OF THE PREVIOUS STATEMENT. OTHERWISE activity_title shows.
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
DEFAULT CODE...
}

}
[/HIGH]

!!!THE WORST OFFENDER: activity_title.xml
__________________________________
**activity_title.xml**
__________________________________
!!!I AM NOT SURE HOW TO WRITE THIS. IT DOESN'T CURRENTLY WORK.
I want to display two views on a screen. One is a randomly positioned dot bitmaps. I can get that do display with setContentView(...).
I also have two bitmaps and a textview that are arranged via xml layout language and then using setContentView(R.layout.controls...);


________________________________________
DrawV.java
!!!BASICALLY I THINK I HAVE TWO setContentViews(...) THAT I WANT TO DISPLAY AT THE SAME TIME. TELL ME IF YOU WANT MORE INFORMATION.
________________________________________
[HIGH]public class DrawV extends View {
VARIABES...

public DrawV(Context context) {
CREATE CIRCLES (CIRCLE OBJECTS) STORING COORDINATES RANDOMLY CHOSEN...

@Override
protected void onDraw(Canvas canvas) {
DRAW THESE CIRCLES AS BITMAPS...SCREEN IS NOW RANDOMLY COVERED WITH MANY DOTS
}

[/HIGH]
_______________________________________
GameActivity.java !!!STARTING .JAVA
_______________________________________
[HIGH]public class GameActivity extends Activity {
private DrawV drawView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

drawView = new DrawV(this);
setContentView(R.layout.activity_title); !!!SHOWS LAYOUT (HOPEFULLY TEXTVIEW, TWO BUTTONS, AND RANDOMLY POSITIONED DOTS (DOTS NEVER WORKS) WHICH IS OVERDONE BY DRAWVIEW...
setContentView(drawView); !!!IF THIS STATEMENT IS SECOND IT RENDERS INTEAD OF THE PREVIOUS STATEMENT. OTHERWISE activity_title shows.
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
DEFAULT CODE...
}

}


!!!THE WORST OFFENDER: activity_title.xml
__________________________________
activity_title.xml
__________________________________
!!!I AM NOT SURE HOW TO WRITE THIS. IT DOESN'T CURRENTLY WORK.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" >
<TextView
android:textColor="#ff0000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="40sp"
android:text="@string/timer"
android:id="@+id/timer">
</TextView>
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_marginLeft="20dp"
android:background="@drawable/stopbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="@string/stopText"
android:id="@+id/stopButton"
android:visibility="gone">
</Button>
<Button
android:layout_marginLeft="20dp"
android:background="@drawable/startbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="@string/startText"
android:id="@+id/startButton">
</Button>
<Button
android:layout_marginRight="20dp"
android:background="@drawable/resetbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="@string/resetText"
android:id="@+id/resetButton">
</Button>
</LinearLayout>
</LinearLayout>

<LinearLayout !!!MESSED UP CODE. DON'T KNOW HOW TO SHOW DOTS USING XML
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<View class="com.category.tap.DrawV"
android:id="@+id/dotpic"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>


</RelativeLayout>
[/HIGH]


If anyone needs more information, let me know.
 
Back
Top Bottom