实现滚动(需要时)到可能太小的手机的功能

发布于 2024-10-03 20:44:51 字数 1299 浏览 1 评论 0原文

我已经在调试器中测试了我的应用程序的许多不同尺寸,并意识到我可能需要一个滚动视图来允许用户查看完整的布局。

问题是我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神爱温柔 2024-10-10 20:44:51

我建议使用自己的 ScrollView 包装每个 LinearLayoutViewFlipper 的每个子级)。虽然您可以包装整个 ViewFlipper,但如果您不希望某个视图滚动,那么将来就无法对其进行修改。

I would recommend wrapping each LinearLayout (each child of the ViewFlipper) with its own ScrollView. While you could wrap the whole ViewFlipper, this is not as modifiable in the future if, for example, you didn't want one view to scroll.

溺ぐ爱和你が 2024-10-10 20:44:51

包装布局(主要的线性布局或你创建的容器)

你必须用“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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文