gpt4 book ai didi

java - 旋转重力

转载 作者:行者123 更新时间:2023-12-01 15:48:14 25 4
gpt4 key购买 nike

旋转器重力似乎只在水平维度上起作用。我希望显示的文本垂直位于顶部并水平居中。这可能吗?我使用 xml spinner 正常样式,如下所示:

<TextView  
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:paddingBottom="5dip"
android:id="@+id/spinnerTarget"
android:gravity="top|center_horizontal"
android:textColor="#ffffff"
/>

最佳答案

您有 wrap_content 高度,因此 View 会围绕文本缩小,并且 View 顶部没有空间放置文本。 android:gravity 仅当 Activity 内有足够的空间容纳内容时才起作用。 center_horizo​​ntal 之所以有效,是因为您已经设置了 fill_parent 的宽度,并且我假设 View 占据了所有屏幕宽度,从而允许内容居中。

尝试重新排列布局,以便在高度方面为 View 提供更多空间。

干杯!

关于java - 旋转重力,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6691087/

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