gpt4 book ai didi

android - 在相对布局中看不到编辑文本(屏幕外)

转载 作者:行者123 更新时间:2023-11-30 02:21:53 26 4
gpt4 key购买 nike

我有以下相对布局,其中有一个 ListView ,下面有一个 EditText。我看不到编辑文本,因为列表占据了整个屏幕。

如何在不滚动的情况下同时在屏幕上显示 ListView 和编辑文本?

我已经尝试了很多布局参数

谢谢

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<TextView
android:id="@+id/textviewassessments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@color/blue_alpha_background"
android:textColor="#FFFFFF"
android:text="Assessments" />

<ListView
android:id="@+id/assessmentslist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:background="#8fff"
android:cacheColorHint="#0000"
android:padding="5dp"
android:divider="#FFCC00"
android:dividerHeight="4px"
android:layout_below="@id/textviewassessments" >
</ListView>

<EditText
android:id="@+id/editTextassessments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="1"
android:lines="7"
android:inputType="textMultiLine"
android:hint="Please type any comments..."
android:layout_below="@id/assessmentslist" >
</EditText>

</RelativeLayout>

最佳答案

如果你想使用 RelativeLayout 那么你应该把一个元素放在底部,另一个放在上面。 sample (未测试)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<EditText
android:id="@+id/editTextassessments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="1"
android:lines="7"
android:inputType="textMultiLine"
android:hint="Please type any comments..."
android:layout_alignParentBottom="true" /> <!-- this will put the element on the bottom of the screen -->



<TextView
android:id="@+id/textviewassessments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@color/blue_alpha_background"
android:textColor="#FFFFFF"
android:text="Assessments"
android:layout_alignParentTop="true"
/> <!-- this will align the element to the head -->

<ListView
android:id="@+id/assessmentslist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:background="#8fff"
android:cacheColorHint="#0000"
android:padding="5dp"
android:divider="#FFCC00"
android:dividerHeight="4px"
android:layout_below="@id/textviewassessments"
android:layout_above="@id/editTextassessments"
/> <!-- this will put the the list between the both elements and stretch its size due match parent -->


</RelativeLayout>

关于android - 在相对布局中看不到编辑文本(屏幕外),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28370320/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com