2011-10-10 57 views
3

我在RelativeLayout中使用HorizontalScrollView。它在1.6 + API上工作正常,但在1.5 API上,HorizontalScrollView不滾動,問題是什麼?RelativeLayout中的Horizo​​ntalScrollView:在1.6 + API上正常工作,但不在1.5 API

在1.5 API(3)上,您只能看到HorizontalScrollView的第一部分,並且根本沒有滾動,而它似乎在API4及更高版本上正常工作。

要回答的問題,這裏使用了一些代碼:

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

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:layout_width="fill_parent"  
android:layout_height="fill_parent" 
android:orientation="vertical"  > 

<HorizontalScrollView 
android:id="@+id/pscroll" 
android:scrollbars="horizontal" 
android:orientation="horizontal" 
android:layout_width="fill_parent"  
android:layout_height="wrap_content" 
android:layout_below="@id/ad" 
android:fillViewport="true" 
android:scrollbarAlwaysDrawHorizontalTrack="true">  

<LinearLayout android:orientation="horizontal" android:id="@+id/LinearLayout01"  android:scrollbars="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> 
        <ImageButton android:id="@+id/P1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> 
      <ImageButton android:id="@+id/P2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> 
+0

你能發佈你用來創建佈局的標記嗎? –

+1

另外,開發1.6版之前的android就像開發現代應用程序在windows 98上工作一樣。當然,有些商業案例,但是...在某些時候你應該放手:) – yep

回答

1

編輯:精緻,基於斷的負反饋(顯然是人們期望通過這個舉辦了手)

滾動視圖意思包含佈局,而不是相反。因此你的佈局應該是:

<HorizontalScrollView android:id="@+id/pscroll" 
    android:scrollbars="horizontal" android:orientation="horizontal" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_below="@id/ad" android:fillViewport="true" 
    android:scrollbarAlwaysDrawHorizontalTrack="true"> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 

     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:orientation="vertical"> 

     <LinearLayout android:orientation="horizontal" 
      android:id="@+id/LinearLayout01" android:scrollbars="horizontal" 
      android:layout_width="fill_parent" android:layout_height="wrap_content"> 
      <ImageButton android:id="@+id/P1" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
      <ImageButton android:id="@+id/P2" android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
     </LinearLayout> 
    </RelativeLayout> 
</HorizontalScrollView> 
+0

請仔細閱讀問題是特定於Horizo​​ntalScroll視圖在1.5中無法按預期工作,但在1.6 API級別4中運行良好 –

+0

沒有理由標記我的答案。他可以將「ScrollView」替換爲「Horizo​​ntalScrollView」。我確實讀過這個問題,答案是他正在顛倒他放置佈局和滾動視圖的位置。 scrollview應該包含一個佈局,這是我在這裏提到的。我不打算給出一個不需要理解的答案,而你顯然沒有理解我的答案。 – eplewis89

相關問題