gpt4 book ai didi

android - fragment 布局仅显示第一个元素(TextView)

转载 作者:行者123 更新时间:2023-11-29 15:51:18 25 4
gpt4 key购买 nike

我有两个 fragment ,根据手机是横向还是纵向模式显示。然而,两者都只显示第一个元素,而不显示像 EditText 或 Buttons 之后的其他元素。有解决办法吗?

下午布局

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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/portrait_message"
android:textColor="#000000"
android:textSize="100px"/>


<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter First Time"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Second Time"/>

</LinearLayout>

activity_main.xml

<LinearLayout 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"
tools:context=".MainActivity"
android:orientation="horizontal">

<fragment
android:name="com.android.madpracticaltest.LM_Fragment"
android:id="@+id/lm_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>

<fragment
android:name="com.android.madpracticaltest.PM_Fragment"
android:id="@+id/pm_fragment"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent"/>

<Button
android:id="@+id/button_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>

</LinearLayout>

最佳答案

pm_layout 中,您有带 orientation="horizo​​ntal"LinearLayout 及其子项的宽度为 match_parent ,所以你应该只会看到第一个 TextView

关于android - fragment 布局仅显示第一个元素(TextView),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29904285/

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