我想在屏幕上顯示兩個視圖。一個是隨機定位的點位圖。我可以用setContentView(...)來顯示。 我也有兩個位圖和一個textview,它們是通過xml佈局語言進行排列,然後使用setContentView(R.layout.activity_title);Android:使用XML的彼此之間的兩個視圖
DrawV.java !!!我基本上認爲我有兩個setContentViews(...),我要陳列在同一時間。告訴我,如果你想知道更多的信息。
公共類DrawV擴展視圖{ 變中......
公共DrawV(上下文的背景下){ 建立社交圈(CIRCLE對象)存儲視點的座標隨機選擇...
@覆蓋 保護無效onDraw(畫布畫布){ 將這些圈子畫成BITMAPS ...畫面現在隨機覆蓋很多個點 }
GameActivity.java
公共類GameActivity延伸活動{ 私人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...
}
}
!!!罪魁禍首:activity_title.xml
activity_title.xml
!!!我是不知道如何寫這個。它目前不工作。 我想在屏幕上顯示兩個視圖。一個是隨機定位的點位圖。我可以用setContentView(...)來顯示。 我也有兩個位圖和一個textview,通過XML佈局語言,然後使用setContentView(R.layout.controls ...);
DrawV.java !!!我基本上認爲我有兩個setContentViews(...),我要陳列在同一時間。告訴我,如果你想知道更多的信息。
公共類DrawV擴展視圖{ 變中......
公共DrawV(上下文的背景下){ 建立社交圈(CIRCLE對象)存儲視點的座標隨機選擇...
@覆蓋 保護無效onDraw(畫布畫布){ 繪製這些圓形作爲位圖...屏已RANDOMLY有許多點 }
GameActivity.java涵蓋的!STARTING .JAVA
公共類GameActivity延伸活動{ 私人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...
}
}
!!!罪魁禍首: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>
如果有人需要更多的信息,讓我知道。
嘗試使用'CTRL + k'突出的代碼,因爲它是很難讀 –
如何使東西查看?我是否需要更改View或RelativeLayout或FrameLayout或以上所有內容? – user963070
使用RelativeLayout! –