开发者

Implementing the ability to scroll (when needed) to phones that might be too small

开发者 https://www.devze.com 2023-01-26 05:03 出处:网络
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.

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开发者_StackOverflow中文版 -->
<!-- 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!


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.


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消