gpt4 book ai didi

图标下方的 Android 文本(按钮)

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

我正在尝试创建一个主入口界面。我将创建六个按钮,每个按钮将打开另一个 Activity 。对于每个按钮,我希望它有一个大图标,按钮下方有文字。目前,我可以在按钮上显示图像,但我不知道如何让文本显示在按钮下方。我试图将文本直接放在图像上,但看起来不太好。这是按钮第一行(两个按钮)的部分

  <LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2" >

<Button
android:id="@+id/btn1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/ic_my_icon" />

<Button
android:id="@+id/btn2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/ic_my_icon2" />
</LinearLayout>

这就是我要说的。除此之外,我希望图标是一个椭圆形按钮。我想要的结果有点像这篇文章中的图片,除了我想要带有图片和文本的六个椭圆形按钮。 Round buttons with icon in center and text under icon

非常感谢您的帮助。

最佳答案

使用drawableTop属性如下:

<Button
android:id="@+id/btn2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="This text is below the image"
android:drawableTop="@drawable/ic_my_icon2" />

参见引用文献 android:drawableTopButton documentation 上的这个简单示例使用 drawableLeft

关于图标下方的 Android 文本(按钮),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23165585/

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