Add*_*tar 1 xml android button
我正在尝试构建Android应用程序,需要构建一个带有两个图像和一些文本的按钮.
这是示例图像:
我如何在Android中构建此按钮?任何帮助,将不胜感激 .
这里有一些代码可以帮助您入门.让我们从背景开始.如果没有为您提供该背景并且您必须自己创建它,那么我们创建一个custom_button_bg.xml文件并添加到您的drawable文件夹中.
custom_button_bg.xml注意:我只是为你做基本的形状.根据需要调整阴影和角半径
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:endColor="@color/teal"
android:startColor="@color/teal"/>
<corners android:radius="4dp"/>
<stroke
android:width="1dp"
android:color="@color/shadow"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
现在只需创建您的布局,如下所示.只需替换src和标签.
<RelativeLayout
android:layout_width="160dp"
android:layout_height="80dp"
android:gravity="center_vertical"
android:background="@drawable/custom_rounded_white_button">
<ImageView
android:id="@+id/iv_video_cam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/video_cam"/>
<TextView
android:id="@+id/tv_desc"
android:layout_toRightOf="@+id/iv_video_cam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="See a Medical \nDoctor Now"/>
<ImageView
android:layout_toRightOf="@+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
干杯!
归档时间: |
|
查看次数: |
1710 次 |
最近记录: |