Android的 - 边框按钮 [英] Android - border for button

查看:239
本文介绍了Android的 - 边框按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加边框按钮?是否有可能做到这一点,而不诉诸使用的图片吗?

How do I add a border to a button? Is it possible to do this without resorting to use of images?

推荐答案

您可以定义按钮的形状为dymmeh指出。为了给它一个边框,使用<中风> 元素。添加在水库这个xml文件/文件夹绘制的button_boarder.xml:

You can define your button as a shape as dymmeh points out. To give it a border, use the <stroke> element. Add this xml file in res/drawable folder as button_boarder.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle">
  <gradient android:startColor="#FFFFFF" 
    android:endColor="#00FF00"
    android:angle="270" />
  <corners android:radius="3dp" />
  <stroke android:width="5px" android:color="#000000" />
</shape>

然后通过

 <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:background="@drawable/button_boarder"
    android:text="Button" 
 />

这篇关于Android的 - 边框按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆