2011-06-10 91 views
0

如果在scrollview中,我有一個相對佈局,其中有兩個textview,其中一個textview有屬性android:layout_alignParentBottom =「true」。可以在屏幕底部對齊這個文本視圖嗎?android佈局東西

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
     > 
<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

    <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="blabla"/> 

    <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:text="blabla2"/> 

</RelativeLayout> 

</ScrollView> 

回答

0

如果您想要將TextView的底部對齊,並將其餘的UI調整爲可滾動。那麼你的佈局應該是這樣的。

<?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"> 
<ScrollView android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <TextView android:layout_width="fill_parent" 
      android:layout_height="wrap_content" android:text="blabla" /> 
    </RelativeLayout> 
</ScrollView> 
<TextView android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:layout_alignParentBottom="true" 
    android:text="blabla2" /> 
    </RelativeLayout> 

希望這會有所幫助。

+0

我希望我的所有物品都可以滾動,因爲將來可能會在頁面上出現多個物品,但我必須在屏幕底部保留一件物品 – 2011-06-10 23:27:15

+0

糾正我,如果我錯了,我從您的評論中瞭解到,你想要n-1個可滾動的項目和第n個項目(在上面的例子中是blabla2)應該總是在屏幕的底部,這意味着用戶總是可見的。如果這是你的情況,那麼你只需要在ScrollView中提到的RelativeLayout中添加所有的n-1視圖。因此,n-1視圖將可滾動,第n個視圖始終固定在底部。 – Gopal 2011-06-11 00:02:19

+0

所以在我看來必須是6個項目。在肖像中,最後一個必須在屏幕的底部(並且它們都適合hdpi設備的縱向模式,因爲mdpi它們不適合),但是在橫向上它們不適合,所以這就是爲什麼我需要將它們放入滾動視圖... – 2011-06-11 00:09:03