【问题标题】:Android custom buttons layoutAndroid 自定义按钮布局
【发布时间】:2011-08-27 19:16:05
【问题描述】:

如何使用 onclick 处理程序为荷兰创建像“ABN Amro Bankieren”应用程序这样的按钮?

Screenshot ABN Amro app

【问题讨论】:

    标签: android layout


    【解决方案1】:

    您必须为每 3 个顶部、中心和底部按钮设置 2 个按下且正常(可能是 4 个用于聚焦和禁用)xml 布局。 这是正常状态的中心按钮的示例 xml 是

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="#F7FCF6"/>
        <stroke android:width="2sp" android:color="#9FA89F"/>      
    </shape>
    

    要使其圆角,您可以使用顶部按钮的角标签

    <corners android:bottomLeftRadius="0.1sp"
    android:bottomRightRadius="0.1sp" android:topLeftRadius="7sp"
    android:topRightRadius="7sp" />
    

    这可能会导致 xml 布局编辑器出现问题,但在模拟器或真实设备上会很好

    【讨论】:

    • 该死,如果我必须为所有按钮创建至少 2 个 xml 文档,这会破坏我的文件夹结构 :') 并使用 我在周围设置了 1px 边框.. 但是如何在两侧添加边框?
    • 那么最好在按钮上加上9 patch Images就可以实现你想要的了。
    猜你喜欢
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 2016-09-06
    • 1970-01-01
    相关资源
    最近更新 更多