2011-04-08 73 views
0

我想在我的視圖中添加滾動視圖。根據我的放置,所有元素都正確顯示在視圖上。我已將「LogoutLabel」和「LogoutButton」放置到android:layout_alignParentBottom = "true"將它們附加到視圖的底部。但我的問題是,當我添加滾動視圖到我的視圖「LogoutLabel」和「LogoutButton」改變其位置並進入視圖的中間即不保持在底部。我希望他們在在視圖上啓用滾動的視圖底部。無法將UI元素添加到Android視圖的底部

請任何人都有這個解決方案。

感謝

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


<TextView android:id="@+id/SettingsLabel"/> 

<TextView android:id="@+id/ProfileLabel"/> 

<Button android:id="@+id/EditButton"/> 


<TextView android:id="@+id/MyIdLabel"/> 

<TextView android:id="@+id/idLabel"/> 

<TextView android:id="@+id/EmailIdLabel"/> 

<TextView android:id="@+id/emailLabel"/> 

<TextView android:id="@+id/PasswordIdLabel"/> 

<TextView android:id="@+id/passwordLabel"/> 

<TextView android:id="@+id/AccountLabel" /> 

<TextView 
android:id="@+id/LogoutLabel" 
android:layout_width="200sp" 
android:layout_height="wrap_content" 
android:text="Do not want to Logout?" 
android:layout_alignParentBottom = "true" 
android:textColor = "#000000" 
android:paddingLeft = "10px"/> 

<Button 
android:id="@+id/LogoutButton" 
android:layout_height="wrap_content" 
android:text="Logout" 
android:layout_alignBaseline = "@id/LogoutLabel" 
android:layout_alignParentRight = "true" 
android:layout_alignParentBottom = "true" 
android:layout_width="100sp"/> 

</RelativeLayout> 
+0

@Kartik:鏈接不起作用。 – Salil 2011-04-08 08:15:41

+0

yes鏈接無效。 – Rishi 2011-04-08 08:48:51

+0

好的。我正在刪除它。當我上個月遇到同樣的問題時,它正在工作。 – 2011-04-08 10:43:06

回答

0

假設你想要的logoutLabel和logoutButton的AccountLabel下面使用android_layoutBelow = 「@ ID/AccountLabel」

<TextView 
android:id="@+id/LogoutLabel" 
android:layout_width="200sp" 
android:layout_height="wrap_content" 
android:text="Do not want to Logout?" 
android:layout_alignParentBottom = "true" 
android:textColor = "#000000" 
android:paddingLeft = "10px" 
android:layout_below="@id/AccountLabel"/> 

<Button 
android:id="@+id/LogoutButton" 
android:layout_below="@id/AccountLabel" 
android:layout_height="wrap_content" 
android:text="Logout" 
android:layout_alignBaseline = "@id/LogoutLabel" 
android:layout_alignParentRight = "true" 
android:layout_alignParentBottom = "true" 
android:layout_width="100sp"/> 

希望這有助於。

-Salil

+0

謝謝salil爲您的答案,但我知道這我已經用它來垂直所有我的用戶界面元素,但在我的情況下,我希望這兩個textview和按鈕對齊底部 – Rishi 2011-04-08 08:12:23

+0

你的意思是說,這兩個控件不應該是一個部分的scrollView,如果是的話,然後嘗試通過在RelativeLayout中創建另一個LinearLayout並在那裏添加兩個控件。 – Salil 2011-04-08 08:18:31

+0

不是所有元素都是scrollview的一部分,但我會嘗試將它們放在另一個佈局中的建議 – Rishi 2011-04-08 08:48:10

相關問題