gpt4 book ai didi

android - Android 中的自定义形状按钮

转载 作者:行者123 更新时间:2023-11-30 02:22:03 26 4
gpt4 key购买 nike

如何制作一个自定义形状的按钮,就像我在 Android 中绘制的图像一样?

我想像下面那样实现用户界面。 enter image description here

谁能帮帮我?

提前致谢。

最佳答案

这里有简单的实现方法,只需要使用布局,作品布局是FrameLayout

[图形布局] Graphical Layout

[post.png]

post.png

[add_a_video.png]

enter image description here

[layout.xml]

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

<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageButton4"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="0dp"
android:src="@drawable/add_a_photo" />

<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageButton1"
android:padding="0dp"
android:src="@drawable/facebook" />

<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageButton2"
android:padding="0dp"
android:src="@drawable/facebook" />

<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton2"
android:layout_below="@+id/imageButton2"
android:padding="0dp"
android:src="@drawable/facebook" />

<ImageButton
android:id="@+id/imageButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton3"
android:layout_below="@+id/imageButton3"
android:padding="0dp"
android:src="@drawable/facebook" />

<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageButton1" >

<ImageButton
android:id="@+id/imageButton7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:src="@drawable/post" />

<ImageButton
android:id="@+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:src="@drawable/add_a_video" />
</FrameLayout>

关于android - Android 中的自定义形状按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28340694/

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