【问题标题】:How to make button's color like glass's color in android/eclipse如何在android / eclipse中使按钮的颜色像玻璃的颜色
【发布时间】:2012-07-19 11:25:00
【问题描述】:

是否可以在 android/eclipse 上使按钮的背景颜色像玻璃的颜色?..如果是这样怎么办?如果不是为什么?

感谢您的宝贵时间!...

【问题讨论】:

  • 我不确定你指的是什么。可以发个截图吗?
  • 为按钮设置透明背景为android:background="@android:color/transparent"
  • @AkashG 工作正常....感谢您的关注

标签: android eclipse button


【解决方案1】:

这就是您正在寻找的解决方案。

drawable中使用这个xml

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

<item android:state_focused="false">
    <shape >
        <gradient 
            android:startColor="#2F000000" 
            android:endColor="#2fDEDEDE"  
            android:angle="270" />
        <!-- <stroke 
            android:width="1dp" 
            android:color="#bb00ff00" /> -->
        <corners 
            android:radius="3dp" />
        <padding 
            android:left="10dp" 
            android:top="10dp" android:right="10dp" 
            android:bottom="10dp" />
    </shape>
</item>

<item android:state_pressed="true" >

    <shape>
        <gradient 
            android:startColor="#2F000000" 
            android:endColor="#2fDEDEDE" 
            android:angle="270" />
       <!--  <stroke 
            android:width="1dp" 
            android:color="#bb00ff00" /> -->
        <corners 
            android:radius="3dp" />
        <padding 
            android:left="10dp" 
            android:top="10dp" android:right="10dp" 
            android:bottom="10dp" />
    </shape>
</item>

<item>
    <shape>
         <gradient
            android:startColor="#2F000000" 
            android:endColor="#2fDEDEDE" 
            android:angle="180" />
            <!-- <gradient
            android:startColor="@color/cream_dark"
            android:endColor="@color/cream"
            android:angle="270"/> -->

         <!--  <stroke 
            android:width="1dp" 
            android:color="#ffffffff" />  -->
        <corners
            android:bottomRightRadius="3dp"
            android:bottomLeftRadius="3dp"
            android:topLeftRadius="3dp"
            android:topRightRadius="3dp"/>
        <padding 
            android:left="10dp" 
            android:top="10dp" android:right="10dp" 
            android:bottom="10dp" />
    </shape>
</item>

</selector>

usage

  <Button android:id="@+id/text1"       
        android:layout_marginTop="200dp"
        android:layout_width="fill_parent"
        android:gravity="center"
        android:textColor="#FF1414"
        android:background="@drawable/btn_darkblue"=========>this is the button background
        android:text="Ram kiran"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        android:textSize="15dp"
        android:layout_height="60dp"        
        /> 

看起来像

【讨论】:

  • thanx .its 帮助了我很多
【解决方案2】:

尝试将透明背景设置为按钮

android:background="@android:color/transparent"

【讨论】:

    【解决方案3】:

    我同意 Cata,但如果这些对您有帮助,您也可以使用形状或使用半透明颜色。您可以在 vogella.combetaful.com 中查看有关形状的一些主要细节

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-03
      • 2012-10-15
      • 1970-01-01
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 2012-06-29
      • 2010-12-24
      相关资源
      最近更新 更多