简体   繁体   English

如何禁用水平滚动视图?

[英]how to disable horizontal scroll-view?

I'm using original Gallery app from the ICS source code. 我正在使用ICS源代码中的原始Gallery应用程序。 And Now the thing is, I want to disable the horizontal scroll and implement it by vertical scroll in Grid. 现在,我想禁用水平滚动并通过Grid中的垂直滚动实现它。 How to do this ? 这该怎么做 ?

try this 尝试这个

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">

Or try like this... 或者像这样尝试...

One programmatic way of doing this, that I can think of, is to create a super class that extends activity and extend all your classes from there. 我可以想到的一种编程方式可以做到这一点,即创建一个扩展活动并从那里扩展所有类的超类。

Have the below setting in the super class in a protected method and call super.xxx() to initiate this: 在受保护的方法的超类中具有以下设置,然后调用super.xxx()来启动此设置:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

In case you what a specific activity in a different way you can simply override this. 如果您以不同的方式进行特定活动,则可以简单地覆盖它。

[I have not tried this yet, but by the knowledge of OOP this works] [我还没有尝试过,但是根据OOP的知识,它可以工作]

try this: 尝试这个:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM