Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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_Xml_Listview_Scrollview_Android Linearlayout - Fatal编程技术网

Android 在线性布局中调整scrollview的高度属性

Android 在线性布局中调整scrollview的高度属性,android,xml,listview,scrollview,android-linearlayout,Android,Xml,Listview,Scrollview,Android Linearlayout,我的listview中有一个项目的布局。我的问题是滚动视图。我存储在其中的注释textview的长度可以从2个单词到255个字符不等。这在我的listview中产生了一个问题,因为当出现的文本很少时,它会与当前设置留下巨大的差距。我不想去掉权重系统,因为它对我的布局中的所有其他项目都非常有用,但是我不知道如何在这里使用它,这样滚动视图的高度就包围了内容,不会占用更多的空间。我已经尝试为我的scrollview设置一个固定的高度,同时去掉它的权重,并使用包装内容,但是当有大量文本时,包装内容不起作

我的listview中有一个项目的布局。我的问题是滚动视图。我存储在其中的注释textview的长度可以从2个单词到255个字符不等。这在我的listview中产生了一个问题,因为当出现的文本很少时,它会与当前设置留下巨大的差距。我不想去掉权重系统,因为它对我的布局中的所有其他项目都非常有用,但是我不知道如何在这里使用它,这样滚动视图的高度就包围了内容,不会占用更多的空间。我已经尝试为我的scrollview设置一个固定的高度,同时去掉它的权重,并使用包装内容,但是当有大量文本时,包装内容不起作用。总而言之,当文本很少时,我会留下一个巨大的空白,当文本很多时,如果我使用包装内容,它会填满整个屏幕,破坏使用滚动视图来节省空间的整个意义

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="220dp"
android:orientation="vertical"
android:weightSum="250">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="20"
    android:orientation="horizontal"
    android:weightSum="100">


    <TextView
        android:layout_width="0dp"
    android:id="@+id/leaguetxt"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="50"
        android:gravity="center"
        android:text="English Premier League"
        android:textColor="#067103"
        android:textStyle="bold" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/datetxt"
        android:layout_gravity="center"
        android:layout_weight="50"
        android:gravity="center"
        android:text="BET UNTIL : 23/05/2015 15:00 GMT"
        android:textColor="#067103"
        android:textSize="12sp"
        android:textStyle="italic" />


</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="35">

    <TextView
        android:id="@+id/teamstxt"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:gravity="center_horizontal"
        android:text="Sevilla FC - FC Barcelona"
        android:textColor="#067103"
        android:textSize="23sp"
        android:textStyle="bold" />

</LinearLayout>



<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="40"
    android:orientation="horizontal">
    <!-- Product id (pid) - will be HIDDEN - used to pass to other activity -->


    <!-- Name Label -->
    <TextView
        android:layout_width="0dp"
        android:id="@+id/bettxt"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_weight="30"
        android:gravity="center"
        android:textSize="19sp"
        android:text="FC Barcelona Win and BTTS"
        android:textColor="#067103"
        android:textStyle="" />





</LinearLayout>


<LinearLayout
    android:layout_width="fill_parent"
    android:layout_weight="20"
    android:weightSum="100"
    android:orientation="horizontal"
    android:layout_height="0dp">

    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:text="DIFFICULTY : "
        android:layout_gravity="center"
        android:gravity="right"
        android:textColor="#067103"
        android:textStyle="italic"
        android:layout_weight="50"/>
    <TextView
        android:id="@+id/difficultytxt"
        android:layout_weight="50"
        android:textStyle="bold"
        android:layout_gravity="center"
        android:gravity="left"
        android:textColor="#067103"
        android:text="MEDIUM RISK"
        android:layout_width="0dp"
        android:layout_height="fill_parent" />
</LinearLayout>
<ScrollView
    android:layout_width="fill_parent"
    android:layout_weight="90"
    android:layout_height="0dp">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:layout_width="fill_parent"
        android:id="@+id/commenttxt"
        android:layout_height="fill_parent"
        android:textColor="#067103"
        android:text = ""/>
</LinearLayout>

</ScrollView>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_weight="50"
    android:weightSum="100"
    android:orientation="horizontal"
    android:layout_height="0dp">
    <TextView
        android:layout_width="0dp"
        android:layout_weight="40"
        android:layout_height="fill_parent" />
    <Button
        android:id="@+id/oddsbutton"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="20"
        android:layout_gravity="center"
        android:gravity="center"
        android:onClick="SelectBet"
        android:text="3.60"
        android:textColor="#067103"
        android:textSize="18sp" />
</LinearLayout>


您不应该在列表项中使用滚动视图。滚动列表时会出现小故障,因为您将同时滚动列表和项目的滚动视图。同时,它也会导致计算滚动视图的高度时出现问题,例如您似乎正在体验的滚动视图

我认为你应该让你的评论块包装你的内容,并修改你的布局,以摆脱你的布局重量。如果您不想总是显示较长的注释,可以将它们以一定的长度删除,并添加一个按钮来显示/隐藏完整的注释