如何在安卓中创建透明圆角按钮?

4
我希望创建类似于 这个 的登录和注册按钮。

使用裸手..(请参阅http://developer.android.com/reference/android/widget/Button.html和http://developer.android.com/guide/topics/ui/controls/button.html) - user180100
1
欢迎来到StackOverflow!你尝试过什么,遇到了什么问题? - OneCricketeer
谢谢你的回答,我没有关键词可以搜索,我会尝试一下。非常感谢。 - Quang Dai Ngo
1个回答

6

将button.xml包含在您的布局中,并通过为其设置id或将边框设置为按钮来将其用作按钮,以便获得相同的结果。

button.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="wrap_content"
                  android:background="@drawable/border">

        <TextView android:id="@+id/skillTextView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Cleaner"
              android:textSize="@dimen/abc_text_size_medium_material"
              android:textColor="@color/text_grey"
              android:layout_margin="@dimen/normal_margin"
              android:layout_centerInParent="true"
    />
    </RelativeLayout>

drawable/border.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners
            android:radius="5dp"
            />
    <stroke
            android:width="1dp"
            android:color="@color/white" />
</shape>

它正在工作,谢谢你的回答! - Quang Dai Ngo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接