Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在scrollview中将版面高度设置为除操作栏和状态栏之外的一个屏幕高度_Android_Layout_Alignment_Scrollview - Fatal编程技术网

Android 如何在scrollview中将版面高度设置为除操作栏和状态栏之外的一个屏幕高度

Android 如何在scrollview中将版面高度设置为除操作栏和状态栏之外的一个屏幕高度,android,layout,alignment,scrollview,Android,Layout,Alignment,Scrollview,我在scrollview中有一个布局,我在第一个布局的末尾添加了另一个布局。实际上,我正在尝试做一个单页设计,其他视图将在滚动后显示。我试图将linearlayout1和linearlayout2放到另一个视图中,但没有成功。我还设置了scrollview android:fillViewport=“true”,但它使scrollview具有屏幕大小 android:layout_width="fill_parent" android:layout_height=

我在scrollview中有一个布局,我在第一个布局的末尾添加了另一个布局。实际上,我正在尝试做一个单页设计,其他视图将在滚动后显示。我试图将linearlayout1和linearlayout2放到另一个视图中,但没有成功。我还设置了scrollview android:fillViewport=“true”,但它使scrollview具有屏幕大小

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
我添加了一个我想要的图像,但也可以是一个视图,我的意思是lin1和lin2在一起

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
我可以为一部手机设置宽度和高度,但我想为每个屏幕设置宽度和高度。比如雅虎天气应用程序。他们为第一个视图做了一个布局,并从屏幕的末尾开始另一个视图。我尝试了很多东西,但我无法想象如何放置布局。你能帮我吗

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
谢谢你的帮助

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
这是我想要的

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
以下是我试过的:

<?xml version="1.0" encoding="utf-8"?>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scroller"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/linearlayout1"
                android:background="@android:color/holo_purple"
                android:layout_width="match_parent"
                android:layout_height="350dp" >

                <TextView
                    android:text="LinearLayout1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/linearlayout2"
                android:background="@android:color/holo_blue_bright"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:orientation="vertical">

                <TextView
                    android:text="LinearLayout2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </LinearLayout>

            <LinearLayout
                android:background="@android:color/holo_green_light"
                android:layout_width="match_parent"
                android:layout_height="350dp">

                <TextView
                    android:text="LnearLayout3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </LinearLayout>



        </LinearLayout>
    </ScrollView>
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"

但不幸的是,我不能为每个屏幕大小配置这个

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"

试试这个

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"

而不是将高度硬编码为:

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
android:layout_height="250dp"
设置android:layout\u height=“0dp”并使用

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"
android:layout_weight="25"

并且在其他布局中使用权重。权重是这样工作的,如果容器中有3个组件,那么将权重设置为1、2和3=>它们将按照容器的1/6、2/6和3/6的顺序进行。6为1,2,3之和。因此,这里不使用高度350和250,您可以将它们设置为0,并使用权重2.5和3.5或25和35。

请提供您的xml。我猜您需要为您的scrollview添加match_parent height,但是如果没有使用xml编辑的xmlI并添加一个我无法计算的图像,我不能确定我的图像与重量成比例,这没关系,但我想将第一个linearlayout height设置为一个屏幕大小,其他视图将在我滚动后显示?
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"        
        android:layout_below="@+id/action_bar"