如何创建标准的无边框按钮(如上述设计指南中所述)?

我只是查看设计指南,想知道无边界按钮。我凝视了一下,试图在源中查找,但我自己无法将其组合在一起。这是普通的Button小部件,但是您添加了自定义(Android默认)样式?如何制作这些无边界按钮(当然您可以将背景设置为空,但是我没有分隔线)?


这里链接到设计指南:


http://developer.android.com/design/building-blocks/buttons.html

http://developer.android.com/guide/topics/ui/controls/button.html#Borderless

http://img.mukewang.com/5db001240001d67507000373.jpg


神不在的星期二
浏览 649回答 3
3回答

慕哥6287543

为了消除一些混乱:这需要2个步骤:将button background属性设置为android:attr / selectableItemBackground会创建一个带有反馈但没有背景的按钮。android:background="?android:attr/selectableItemBackground"将无边界按钮与其余布局分开的行是通过背景为android:attr / dividerVertical的视图完成的android:background="?android:attr/dividerVertical"为了更好地理解,此处是屏幕底部的“确定” /“取消无边界”按钮组合的布局(如上图所示)。<RelativeLayout&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="48dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentBottom="true">&nbsp; &nbsp; &nbsp; &nbsp; <View&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="1dip"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginLeft="4dip"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginRight="4dip"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="?android:attr/dividerVertical"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentTop="true"/>&nbsp; &nbsp; &nbsp; &nbsp; <View&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/ViewColorPickerHelper"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="1dip"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentTop="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentBottom="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginBottom="4dip"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop="4dip"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="?android:attr/dividerVertical"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_centerHorizontal="true"/>&nbsp; &nbsp; &nbsp; &nbsp; <Button&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/BtnColorPickerCancel"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentLeft="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentTop="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_toLeftOf="@id/ViewColorPickerHelper"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="?android:attr/selectableItemBackground"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:text="@android:string/cancel"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentBottom="true"/>&nbsp; &nbsp; &nbsp; &nbsp; <Button&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/BtnColorPickerOk"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentRight="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentTop="true"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="?android:attr/selectableItemBackground"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:text="@android:string/ok"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_alignParentBottom="true"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_toRightOf="@id/ViewColorPickerHelper"/>&nbsp; &nbsp; </RelativeLayout>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Android