gpt4 book ai didi

Android:垂直LinearLayout中的ScrollView

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:38:07 25 4
gpt4 key购买 nike

我正在为 Android 设备制作一个应用程序,我试图在 LinearLayout 中放置一个 ScrollView,但是当我尝试这样做时,ScrollView 占用了 LinearLayout 中 ScrollView 之后的所有空间和元素。

例如:
如果 ScrollView 不是“完整的”:
http://kakko76.free.fr/scroll2.jpg
如果 ScrollView 是“满的”:
http://kakko76.free.fr/scroll1.png

如您所见,按钮消失了...
这是此 Activity 的代码:

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_marginLeft="50dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="@drawable/linearlayoutbackground" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nom_des_joueurs"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginBottom="30dp" />

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:id="@+id/llPlayersName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

</LinearLayout>

</ScrollView>

<Button
android:id="@+id/okPlayersName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/ok"
android:background="@drawable/backgroundbutton"
android:layout_marginTop="30dp" />
</LinearLayout>

在 ScrollView 中的 LinearLayout 中添加元素之后。
有什么解决办法吗?
谢谢。

最佳答案

尝试以下操作:

android:layout_height="0dp"
android:layout_weight="1"

这会告诉您的 ScrollView 占用所有未被其他元素占用的剩余空间。

关于Android:垂直LinearLayout中的ScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12130797/

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