gpt4 book ai didi

android - android :layout_gravity?发生了什么

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

我想知道 android:layout_gravity 发生了什么。我的代码如下所示:

<Button
android:id="@+id/test_button"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="test"
android:textSize="25sp" />

但是中心在按钮上完全没有做任何事情,eclipse 甚至在他们的下拉菜单中也没有。他们现在有另一种方法吗?

最佳答案

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<Button
android:id="@+id/test_button"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="test"
android:textSize="25sp" />

</LinearLayout?

android:layout_gravityLinearLayout.LayoutParams

因此,它适用于 LinearLayout。

或者像下面这样改变(不管父级)

<Button
android:id="@+id/test_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
android:textSize="25sp" />

关于android - android :layout_gravity?发生了什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16974845/

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