【问题标题】:Custom button with gradient in stroke笔划中带有渐变的自定义按钮
【发布时间】:2014-10-21 07:28:11
【问题描述】:

我可以在按钮的描边(边框)上给出渐变颜色吗? 请尽快帮助我。

<item>
  <shape android:shape="rectangle">
    <corners  android:radius="5dp" />
    <solid android:color="#6053565B" />
    <size android:height="40dp"/>
    <stroke android:width="2px" android:color="#6053565B" />
  </shape>
 </item>

【问题讨论】:

标签: android


【解决方案1】:

像这样在您的可绘制文件夹中创建一个可绘制形状,并将其命名为按钮

<?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="#FFFFFF"
        android:angle="270" />
      <corners android:radius="3dp" />
      <stroke android:width="5px" android:color="#eecc68" />
    </shape>



  and in your .xml put like below,

<Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginLeft="52dp"
        android:layout_marginTop="39dp"
        android:background="@drawable/button"
        android:text="Button" />

【讨论】:

    【解决方案2】:

    This 是您的问题的解决方案。如果您的按钮背景是固定颜色,您可以使用它。我仍在寻找相同的透明按钮和渐变边框。

    【讨论】:

    • 当然。最有可能的是,我会选择 9 个补丁图像。这很容易。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多