gpt4 book ai didi

Android,layout_above 不工作

转载 作者:搜寻专家 更新时间:2023-11-01 07:46:43 24 4
gpt4 key购买 nike

我想在屏幕中间、页眉下方和页脚上方显示一些文本。由于此文本很长,我将其嵌套在 ScrollView 中。我尝试了多种解决方案:this , this , this , this ,还有更多……

起初我遇到了两个 relative_layouts 重叠和文本被剪切的问题。最被接受的答案是使用 layout_abovelayout_below,但是当我使用 layout_above 时,文本永远不会显示 .

这是我的 xml 的样子:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">

<ImageView
android:id="@+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="@string/profile_photo"
android:src="@drawable/default_profile"
tools:ignore="RtlHardcoded" />

</RelativeLayout>

<RelativeLayout
android:id="@+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_above="@+id/ln_layout_footer"
android:layout_below="@+id/linear_layout_header">

<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">

<TextView
android:id="@+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/text"/>-
</ScrollView>

</RelativeLayout>

<RelativeLayout
android:id="@+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">

<LinearLayout
android:id="@+id/ln_layout"
android:layout_width="fill_parent"
android:background="@color/gray"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">

<TextView
android:id="@+id/red"
android:textColor="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/red" />

<TextView
android:id="@+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/white"
android:layout_weight="1"
android:gravity="center"
android:text="@string/blue" />

<TextView
android:id="@+id/green"
android:layout_width="match_parent"
android:textColor="@color/white"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/green" />
</LinearLayout>

</RelativeLayout>

最佳答案

在你的ln_layout_footer

设置 android:layout_height="wrap_content"


已编辑

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dark_gray_pressed"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">

<ImageView
android:id="@+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="@string/action_settings"
android:src="@drawable/img_splash_logo"
tools:ignore="RtlHardcoded" />

</RelativeLayout>

<RelativeLayout
android:id="@+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/ln_layout_footer"
android:layout_below="@+id/linear_layout_header">

<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">

<TextView
android:id="@+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/txt_price" />-
</ScrollView>

</RelativeLayout>

<RelativeLayout
android:id="@+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">

<LinearLayout
android:id="@+id/ln_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/dark_gray"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">

<TextView
android:id="@+id/red"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/txt_quantity"
android:textColor="@color/white" />

<TextView
android:id="@+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/txt_material"
android:textColor="@color/white" />

<TextView
android:id="@+id/green"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/msg_enter_user_name"
android:textColor="@color/white" />
</LinearLayout>

</RelativeLayout>

关于Android,layout_above 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42579894/

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