2012-10-09 169 views
0

我使用ICS源代碼中的原創Gallery應用程序。現在的事情是,我想禁用水平滾動並通過Grid中的垂直滾動來實現它。這個怎麼做 ?如何禁用水平滾動視圖?

+0

看到這個http://stackoverflow.com/questions/5763304/disable-滾動視圖,編程 – vnshetty

回答

0

嘗試這樣做的這個

Add android:screenOrientation="portrait" to the activity in the AndroidManifest.xml. For example:

<activity android:name=".SomeActivity" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait"> 

或者嘗試像這樣...

一個編程的方式,我能想到的,是創建延伸的超類活動並從那裏擴展你的所有課程。

已在受保護的方法在超類下面的設置和調用super.xxx()來啓動這樣的:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

如果您有什麼不同的方式具體的活動,你可以簡單地覆蓋這個。

[我沒有試過呢,但OOP的知識這部作品]

0

試試這個:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<ScrollView android:id="@+id/ScrlView" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<Gallery android:id="@+id/gallery" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:gravity="bottom"/> 

</ScrollView> 
</LinearLayout>