亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何創建標準的無邊框按鈕(如上述設計指南中所述)?

如何創建標準的無邊框按鈕(如上述設計指南中所述)?

神不在的星期二 2019-12-05 07:07:43
我只是查看設計指南,想知道無邊界按鈕。我凝視了一下,試圖在源中查找,但我自己無法將其組合在一起。這是普通的Button小部件,但是您添加了自定義(Android默認)樣式?如何制作這些無邊界按鈕(當然您可以將背景設置為空,但是我沒有分隔線)?這里鏈接到設計指南:http://developer.android.com/design/building-blocks/buttons.htmlhttp://developer.android.com/guide/topics/ui/controls/button.html#Borderless
查看完整描述

3 回答

?
慕哥6287543

TA貢獻1831條經驗 獲得超10個贊

為了消除一些混亂:


這需要2個步驟:將button background屬性設置為android:attr / selectableItemBackground會創建一個帶有反饋但沒有背景的按鈕。


android:background="?android:attr/selectableItemBackground"

將無邊界按鈕與其余布局分開的行是通過背景為android:attr / dividerVertical的視圖完成的


android:background="?android:attr/dividerVertical"

為了更好地理解,此處是屏幕底部的“確定” /“取消無邊界”按鈕組合的布局(如上圖所示)。


<RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="48dp"

        android:layout_alignParentBottom="true">

        <View

            android:layout_width="match_parent"

            android:layout_height="1dip"

            android:layout_marginLeft="4dip"

            android:layout_marginRight="4dip"

            android:background="?android:attr/dividerVertical"

            android:layout_alignParentTop="true"/>

        <View

            android:id="@+id/ViewColorPickerHelper"

            android:layout_width="1dip"

            android:layout_height="wrap_content"

            android:layout_alignParentTop="true"

            android:layout_alignParentBottom="true"

            android:layout_marginBottom="4dip"

            android:layout_marginTop="4dip"

            android:background="?android:attr/dividerVertical" 

            android:layout_centerHorizontal="true"/>

        <Button

            android:id="@+id/BtnColorPickerCancel"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_toLeftOf="@id/ViewColorPickerHelper"

            android:background="?android:attr/selectableItemBackground"

            android:text="@android:string/cancel" 

            android:layout_alignParentBottom="true"/>

        <Button

            android:id="@+id/BtnColorPickerOk"

            android:layout_width="wrap_content"

            android:layout_height="match_parent"

            android:layout_alignParentRight="true"

            android:layout_alignParentTop="true"

            android:background="?android:attr/selectableItemBackground"

            android:text="@android:string/ok" 

            android:layout_alignParentBottom="true" 

            android:layout_toRightOf="@id/ViewColorPickerHelper"/>

    </RelativeLayout>



查看完整回答
反對 回復 2019-12-07
  • 3 回答
  • 0 關注
  • 696 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號