English 中文(简体)
独一无二的视力不能在环形中发挥作用 观点
原标题:Layout Weights do not work inside a ScrollView

我愿在<代码>内向几个项目分配布置重量。 View。 但是,<代码>ScrollView 忽视<代码>LinearLayout>> 重量标准/代码>。

我的目标是将布局与2、1、1、4和4的重量分开,但这在<编码>ScrollView内并不适当。

How can I solve this layout problem?

<>strong>main.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:weightSum="4">

        <LinearLayout android:id="@+id/logo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="2"
            android:background="#FFFFFF" />

        <LinearLayout android:id="@+id/logo1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="1"
            android:background="#000000" />


        <LinearLayout android:id="@+id/logobutton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" 
            android:layout_weight="1" 
            android:background="#4B4B4B" />

    </LinearLayout>
</ScrollView>
最佳回答

我以前曾面临这一问题。 Just use android:ompViewport=“true” in You Scroll 观点和看法将填补屏幕上。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >
问题回答

This won t work as you have done it. The child view of a ScrollView should be set to wrap_content. If you set it to fill_parent, it will fill the area of the ScrollView and never scroll, because it won t be larger than the ScrollView.

<代码>layout_ 重量的想法是按比例填充特定区域。

You should set all of the child LinearLayouts layout_height to either wrap_content or a specific size (in dp) and the parent LinearLayout layout_height to wrap_content

As said you need to remove the additional

xmlns:android=“http://schemas.android.com/apk/res/android”

如果它不是布局的根本(第一)因素。

just put this in your scroll view:

<代码>android: 填充电=“true”

在我的经验中,<代码> 填充表=true工程断层。

我通过包装<代码>LinearLayout与另一个版面,如<代码>FrameLayout,解决这一问题。

I hope this helps.

页: 1 认为它会很出色。

www.un.org/spanish/ecosoc 只有一名儿童才能获得出生证明。

android:fillViewport="true"




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签