gpt4 book ai didi

android - 之前工作后布局不显示

转载 作者:行者123 更新时间:2023-11-29 21:02:28 25 4
gpt4 key购买 nike

我正在尝试为我的 Android 项目实现横向布局。我之前让它半工作,除了“leftRightLinear”被底部的按钮布局稍微重叠。自从尝试解决该问题后,我放弃并回滚到我的工作版本,该版本不再工作,我也不知道为什么。pendingLinear 和 semesterLinear 的内容未显示。有什么想法吗?

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainLinear"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/leftRightLinear"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true" >
<LinearLayout
android:id="@+id/leftLinear"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="fill_parent" >
<TextView
android:text="@string/pendingUnits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ScrollView
android:id="@+id/pendingScroll"
android:layout_width="fill_parent"
android:layout_marginBottom="0dp"
android:layout_height="0dp"
android:background="@drawable/border">
<LinearLayout
android:id="@+id/pendingLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/rightLinear"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="fill_parent" >
<TextView
android:text="@string/semesters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ScrollView
android:id="@+id/semesterScroll"
android:layout_width="fill_parent"
android:layout_marginBottom="0dp"
android:layout_height="0dp"
android:background="@drawable/border">
<LinearLayout
android:id="@+id/semesterLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/border_confirm"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/saveButtonSemester"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:onClick="clickSave"
android:text="@string/button_save"
/>
<Button
android:id="@+id/confirmBtn"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/confirm"
android:onClick="clickConfirm"
/>
</LinearLayout>

最佳答案

The contents of pendingLinear and semesterLinear aren't displaying

这是因为你的两个 ScrollView 都设置了 android:layout_height="0dp"。将它们更改为 android:layout_height="fill_content",如下所示:

<ScrollView
android:id="@+id/pendingScroll"
android:layout_width="fill_parent"
android:layout_marginBottom="0dp"
android:layout_height="fill_parent">

关于这个问题

"leftRightLinear" was being overlapped slightly by the button layout at the bottom

要让 leftRightLinear 位于按钮布局之上,首先为按钮布局命名

<LinearLayout
android:id="@+id/buttonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true" >

然后将这个属性添加到leftRightLinear, android:layout_above="@+id/buttonLayout",像这样:

<LinearLayout
android:id="@+id/leftRightLinear"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/buttonLayout"
android:layout_alignParentTop="true" >

结果如下:(左侧 ScrollView 的背景设置为黑色)

layout

关于android - 之前工作后布局不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25614988/

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