C# TextView和ListView的奇怪行为
我试图显示一个配方,有3个主要组成部分:标题与图片,成分列表和方法的文本。 当列表中有很多成分(ListView)时,不会显示方法文本(TextView)。现在有滚动条显示 我试过我想所有的事情:制作一个线性视图,相对视图,框架视图,堆栈视图,滚动视图。有些选项没有帮助,有些拒绝编译C# TextView和ListView的奇怪行为,c#,android-layout,xamarin,C#,Android Layout,Xamarin,我试图显示一个配方,有3个主要组成部分:标题与图片,成分列表和方法的文本。 当列表中有很多成分(ListView)时,不会显示方法文本(TextView)。现在有滚动条显示 我试过我想所有的事情:制作一个线性视图,相对视图,框架视图,堆栈视图,滚动视图。有些选项没有帮助,有些拒绝编译 我需要更多的想法我能做什么。我完全是一堆东西。如果你的listview有很多项目,它会填满屏幕的高度,因为你的textview(方法)是在listview下面定义的,它会在屏幕之外,你看不到它 1.您可以为li
我需要更多的想法我能做什么。我完全是一堆东西。如果你的listview有很多项目,它会填满屏幕的高度,因为你的textview(方法)是在listview下面定义的,它会在屏幕之外,你看不到它 1.您可以为listview定义一个特定的高度,以便它不填充屏幕高度,然后textview(方法)将是可见的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Toolbar
android:minHeight="?android:attr/actionBarSize"
android:background="?android:attr/colorPrimary"
android:minWidth="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar1">
</Toolbar>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/frameLayout"
android:layout_below="@id/toolbar1">
<ImageView
android:id="@+id/recipeImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="top|left"
android:background="@color/list_image_bg_color"
android:src="@drawable/ic_noimage" />
<TextView
android:id="@+id/recipeTextTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textAlignment="viewEnd"
android:layout_marginTop="50dp"
android:background="#22000000"
android:padding="12dp"
android:textSize="22sp"
android:gravity="fill_horizontal|center_vertical"
android:textStyle="bold"
android:layout_gravity="right" />
</FrameLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/textIngredients"
android:layout_below="@id/frameLayout"
android:fitsSystemWindows="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text"
android:layout_below="@id/textIngredients"
android:id="@+id/textMethod"/>
</RelativeLayout>
2.在屏幕底部定义textview(方法),然后将listview置于其上方
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Toolbar
android:minHeight="?android:attr/actionBarSize"
android:background="?android:attr/colorPrimary"
android:minWidth="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar1">
</Toolbar>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/frameLayout"
android:layout_below="@id/toolbar1">
<ImageView
android:id="@+id/recipeImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="top|left"
android:background="@color/list_image_bg_color"
android:src="@drawable/ic_noimage" />
<TextView
android:id="@+id/recipeTextTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textAlignment="viewEnd"
android:layout_marginTop="50dp"
android:background="#22000000"
android:padding="12dp"
android:textSize="22sp"
android:gravity="fill_horizontal|center_vertical"
android:textStyle="bold"
android:layout_gravity="right" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text"
android:layout_alignParentBottom="true"
android:id="@+id/textMethod"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textIngredients"
android:layout_below="@id/frameLayout"
android:layout_above="@id/textMethod"
android:fitsSystemWindows="false" />
</RelativeLayout>
这似乎是一个简单的解决方案!非常感谢。我会在一周左右的时间内检查,在那之前我不会在电脑前。我终于有时间继续我的项目了。你的解决方案奏效了(我同时使用了这两个选项)。非常感谢。