2012-01-27 75 views
2

我在我的項目上有幾個xml佈局。當應用程序啓動時,main.xml佈局會在設備上加載。當我加載第二個XML佈局它從主要infront,但不包括所有的屏幕,你也看到後面是主要的佈局在android中的佈局

第二個佈局是使用match_parent和XML代碼是

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" android:weightSum="1"> 

//something 

</LinearLayout> 

此艾德里安我試圖做的是第二個佈局採取所有的屏幕,而不是能夠看到背面的主。 這是可以做到的嗎?

編輯

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TableLayout android:layout_width="match_parent" 
     android:layout_height="match_parent" > 
    <TableRow > 
     <TextView android:text="Password Recovery" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="match_parent"></TextView> 

    </TableRow> 
    <TableRow > 
    <TextView android:text="Username: " android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
    <EditText android:text=" " android:id="@+id/UsernameRecovery" android:layout_width="100dp" android:layout_height="45dp"></EditText> 
    </TableRow> 

    <TableRow > 

    <Button android:text="Submit" android:id="@+id/SubmitRecoveryPass" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
    <Button android:text="Cancel" android:id="@+id/CancelRecoveryPass" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 

    </TableRow> 
    </TableLayout> 

</LinearLayout> 

我有什麼,以全屏幕改變並沒有能夠看到後面

+0

你應該發佈你實際進行切換的代碼。 – dmon 2012-01-27 01:20:14

+0

你有沒有嘗試過:android:layout_height =「wrap_content」? – 2012-01-27 05:32:15

回答

2

如果你想要的是對單個活動做然後使用隱藏佈局同時顯示另一個佈局。

手段隱藏主佈局,同時打開第二個佈局。主佈局也是如此。

如果你不想讓它在單一活動中完成,那麼試試這個。

創建兩個xml。就像main.xml和second.xml 現在調用第一個活動setContentLayout(R.layout.main); ,同時調用第二個活動,然後setContentLayout(R.layout.second);

由defalut android隱藏第一個活動並顯示第二個活動。

是的,但請確保您在這兩個xml的父佈局上使用fill_parent。

希望它能幫助你。

享受。 :))

+0

它隱藏它,但我的第二個佈局尺寸是根據我在佈局上的數據,並沒有覆蓋所有的屏幕,而且我仍然可以在背面看到第一個佈局。我也用戶fill_parrent在兩個佈局 – prokopis 2012-01-28 00:18:24

+1

您的問題是隻爲xml佈局的目的? – 2012-01-28 04:17:02

+0

我不知道你的問題是什麼。如果問題僅針對第二個佈局的xml,則使用fill_parent作爲第二個xml的父佈局的高度和寬度。 – 2012-01-28 04:20:48