2010-11-20 76 views
1

我有一個linearlayout A包含imageview和scrollview。 scrollview包含第二個線性佈局B 這個想法是有一個固定的標題,而linearLayout B包含多個視圖完全匹配的滾動視圖的高度。將它看作一個TabView,其中所有標籤在滾動視圖中都處於彼此之後。ScrollView的高度0即使fill_parent

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/main_view" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#000000" 
    android:orientation="vertical"> 

<ImageView android:id="@+id/logoImg" 
    android:layout_width="fill_parent" 
    android:gravity="center" 
    android:src="@drawable/logo" 
    android:layout_height="wrap_content"/> 

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_weight="1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

<LinearLayout android:id="@+id/scrollLinear" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
</ScrollView> 
</LinearLayout> 

我試圖通過調用的getHeight上了滾動來實現這一點,則可以用這個高度來每個視圖中的LinearLayout B,而總的getHeight返回0 任何一個想法,什麼是實現這一目標的最簡單的方法?

+0

對不起,但我不明白...你想要一個垂直tabview的等價物?爲什麼使用scrollview呢? – Sephy 2010-11-20 20:35:54

+0

嗯,我想要一個動畫tabview。如果您單擊某個選項卡,則通過將滾動視圖滾動到正確的位置顯示正確的選項卡。我認爲這看起來不錯。我知道我可以使用TabView來實現相同的功能效果,但不是相同的視覺效果。 – Tin 2010-11-21 06:04:28

回答

1

嗯,這個問題是非常古老的,但我會給它一個嘗試:) 它不會缺乏ScrollView中的「fillViewport」嗎?

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_weight="1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

    android:fillViewport="true" 

    > 
相關問題