实现滚动(需要时)到可能太小的手机的功能
我已经在调试器中测试了我的应用程序的许多不同尺寸,并意识到我可能需要一个滚动视图来允许用户查看完整的布局。
问题是我在 main.xml 中使用了带有多个线性布局的脚蹼,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/your_flipper"
android:screenOrientation="portrait"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<!-- the second view on the flipper -->
<!-- ImageView -->
<!-- TextViews -->
<!-- Buttons -->
<!-- Image Buttons -->
</LinearLayout>
<!-- the 3rd view on the flipper -->
<!-- ImageView -->
<!-- TextViews -->
<!-- Buttons -->
<!-- Image Buttons -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
</LinearLayout>
<!-- the 4th view on the flipper -->
<!-- ImageView -->
<!-- TextViews -->
<!-- Buttons -->
<!-- Image Buttons -->
</LinearLayout>
我做了 ImageViews、Buttons、TextViews 等注释,以免代码膨胀 -
这是在我的主 xml 文件中,其中显示了所有布局。如何轻松地为每个布局添加滚动视图,以便如果它对于特定手机的屏幕来说太大,用户可以滚动页面以查看所有内容?
谢谢!
I have tested my app in a debugger for many different sizes, and realized I will probably need a scrollView to allow the user to view the full layout.
The issue, is I use a flipper in my main.xml with multiple linear layouts like so:
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/your_flipper"
android:screenOrientation="portrait"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<!-- the second view on the flipper -->
<!-- ImageView -->
<!-- TextViews -->
<!-- Buttons -->
<!-- Image Buttons -->
</LinearLayout>
<!-- the 3rd view on the flipper -->
<!-- ImageView -->
<!-- TextViews -->
<!-- Buttons -->
<!-- Image Buttons -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
</LinearLayout>
<!-- the 4th view on the flipper -->
<!-- ImageView -->
<!-- TextViews -->
<!-- Buttons -->
<!-- Image Buttons -->
</LinearLayout>
I made the ImageViews, Buttons, TextViews, etc comments so not to bloat the code -
This is in my main xml file, where all the layouts are displayed. How can I go about easily adding a scroll view to each layout, so if it is too big for the screen of a certain phone, the user can scroll through the page to see all the content?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用自己的
ScrollView
包装每个LinearLayout
(ViewFlipper
的每个子级)。虽然您可以包装整个ViewFlipper
,但如果您不希望某个视图滚动,那么将来就无法对其进行修改。I would recommend wrapping each
LinearLayout
(each child of theViewFlipper
) with its ownScrollView
. While you could wrap the wholeViewFlipper
, this is not as modifiable in the future if, for example, you didn't want one view to scroll.包装布局(主要的线性布局或你创建的容器)
你必须用“scrollView”
,如下所示:
http://www.androidpeople.com/android-scrollview-example/
you have to wrap the layout (the main linearlayout or something you create as the container)
with a 「scrollView」 ,
like this :
http://www.androidpeople.com/android-scrollview-example/