【问题标题】:Using one style on several buttons with different background images在具有不同背景图像的多个按钮上使用一种样式
【发布时间】:2015-03-18 10:37:15
【问题描述】:

您好,我正在尝试为一个菜单中的多个按钮设置相同大小和阴影的样式, 我在这里找到了代码How to provide shadow to Button 来帮助我做到这一点,但我希望每个按钮都有不同的背景图像,但是因为我已经使用android:background="@anim/button_menu" 调用了这种样式,所以我无法通过说android:background="@drawable/imageclassroom" 作为背景来更改每个按钮的背景已经被调用。关于如何克服这个问题的任何帮助都会很棒

【问题讨论】:

    标签: android xml android-button android-styles android-background


    【解决方案1】:

    使用此类型制作颜色按钮

     <Leniarlayout
     android:layout_width="match_parent"
     android:layout_hight ="40dp"
     android:background ="#000"
     android:padding ="5dp">
    
     <Button
     android:id="@+id/angry_btn"
     android:text="Button"
     android:textColor="#FFFFFF"
     android:textSize="30sp"
     android:layout_width="270dp"
     android:layout_height="60dp"
     android:background="@drawable/(set image path)"
     android:shadowColor="#A8A8A8"
     android:shadowDx="0"
     android:shadowDy="0"
     android:shadowRadius="5"
     />
     </Leniarlayout>
    

    【讨论】:

    • 这很酷,但不能解决我的问题,我正在尝试将一种样式应用于多个按钮,但也更改每个按钮的背景,使它们看起来都不同
    • 你想要什么样的风格
    • 所有按钮都应该有弧形角,后面有阴影,文字后面有阴影,然后每个按钮都有不同的图像作为背景
    • 你所说的一切都很好,只是我不知道如何将按钮背景设置为图像
    • android: background = "@drawable/image.file
    猜你喜欢
    • 2012-11-26
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    • 2014-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多