{"id":146,"date":"2017-04-15T14:08:49","date_gmt":"2017-04-15T06:08:49","guid":{"rendered":"http:\/\/av16874667.imwork.net:13582\/?p=146"},"modified":"2017-04-15T14:08:49","modified_gmt":"2017-04-15T06:08:49","slug":"android-floatingactionbutton-%e4%bd%bf%e7%94%a8%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.dd-home.top\/?p=146","title":{"rendered":"Android FloatingActionButton \u4f7f\u7528\u4ecb\u7ecd"},"content":{"rendered":"<h2><\/h2>\n<p><!--more--><\/p>\n<h2>1.\u5e03\u5c40\u6587\u4ef6\u4ecb\u7ecd<\/h2>\n<p>\u7531\u4e8e\u4f7f\u7528\u7684RelativeLayout,\u56e0\u6b64\u5e03\u5c40\u65f6\u4f7f\u7528\u7684\u662f\u76f8\u5bf9\u5e03\u5c40.<\/p>\n<pre>&lt;android.support.design.widget.FloatingActionButton\n \u00a0 \u00a0android:id=\"@+id\/fab\"\n \u00a0 \u00a0android:layout_width=\"wrap_content\"\n \u00a0 \u00a0android:layout_height=\"wrap_content\"\n \u00a0 \u00a0android:layout_alignParentBottom=\"true\"\n \u00a0 \u00a0android:layout_alignParentRight=\"true\"\n \u00a0 \u00a0android:src=\"@mipmap\/ic_launcher\"\n \u00a0 \u00a0app:elevation=\"1sp\"\n \u00a0 \u00a0app:backgroundTint=\"#ff87ffeb\"\n \u00a0 \u00a0app:backgroundTintMode=\"src_over\"\n \u00a0 \u00a0app:fabSize=\"mini\"\n \u00a0 \u00a0app:pressedTranslationZ=\"1dp\"\n \u00a0 \u00a0app:rippleColor=\"#33728dff\"\n \u00a0 \u00a0app:useCompatPadding=\"true\" \/&gt;<\/pre>\n<p>a.\u5176\u4e2delevation (\u6d77\u62d4)\u6307FAB\u7684\u60ac\u7a7a\u9ad8\u5ea6.<\/p>\n<p>\u5982\u56fe\u4e3aelevation=&#8221;1sp&#8221; \u548c elevation=&#8221;10sp&#8221;\u7684\u5dee\u522b,\u770b\u51fa\u6709\u660e\u663e\u7684\u9634\u5f71\u5dee\u522b.<\/p>\n<p><img decoding=\"async\" title=\"1462086961993045330.png\" src=\"https:\/\/www.dingqs.date\/ueditor\/jsp\/upload\/image\/20160501\/1462086961993045330.png\" alt=\"blob.png\" \/><img decoding=\"async\" title=\"1462087017806058377.png\" src=\"https:\/\/www.dingqs.date\/ueditor\/jsp\/upload\/image\/20160501\/1462087017806058377.png\" alt=\"blob.png\" \/><\/p>\n<p>b.backgroundTint \u80cc\u666f\u7740\u8272<\/p>\n<p><img decoding=\"async\" title=\"1462087276278032558.png\" src=\"https:\/\/www.dingqs.date\/ueditor\/jsp\/upload\/image\/20160501\/1462087276278032558.png\" alt=\"blob.png\" \/><\/p>\n<p>c.backgroudTintMode \u80cc\u666f\u7740\u8272\u65b9\u5f0f<\/p>\n<p><img decoding=\"async\" title=\"1462087276278032558.png\" src=\"http:\/\/blog.dingqs.date\/ueditor\/jsp\/upload\/image\/20160501\/1462087276278032558.png\" alt=\"blob.png\" \/>src_over<\/p>\n<p><img decoding=\"async\" title=\"1462088020727025306.png\" src=\"https:\/\/www.dingqs.date\/ueditor\/jsp\/upload\/image\/20160501\/1462088020727025306.png\" alt=\"blob.png\" \/>src_in<\/p>\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;\u7a0d\u540e\u770b\u770bbackgroundTintMode<\/p>\n<p>d.fabsize<\/p>\n<p>\u5206\u4e3amini\u548cnormal \u4e24\u79cd\u5927\u5c0f\u65b9\u5f0f<\/p>\n<p>e.pressedTranslationZ\u00a0\u00a0\u00a0\u00a0\u70b9\u51fb\u540e\u5728Z\u8f74\u4e0a\u7684\u6295\u5f71<\/p>\n<p>f.rippleColor\u00a0\u00a0\u00a0\u00a0\u6295\u5f71\u989c\u8272<\/p>\n<p>useCompatPadding<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>2.\u5f15\u7528Android \u5b98\u65b9\u7684XML \u5c5e\u6027<\/h2>\n<hr \/>\n<p><a name=\"attr_android.support.design:elevation\"><\/a><\/p>\n<h4 class=\"jd-details-title\">android.support.design:elevation<\/h4>\n<p>Elevation value for the FAB<\/p>\n<p>Must be a dimension value, which is a floating point number appended with a unit such as &#8220;<code>14.5sp<\/code>&#8220;. Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).<\/p>\n<p>This may also be a reference to a resource (in the form &#8220;<code>@[<em>package<\/em>:]<em>type<\/em>:<em>name<\/em><\/code>&#8220;) or theme attribute (in the form &#8220;<code>?[<em>package<\/em>:][<em>type<\/em>:]<em>name<\/em><\/code>&#8220;) containing a value of this type.<\/p>\n<p>This is a private symbol.<\/p>\n<h5 class=\"jd-tagtitle\">Related Methods<\/h5>\n<ul class=\"nolist list-paddingleft-2\">\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/support\/design\/widget\/FloatingActionButton.html#setCompatElevation(float)\">setCompatElevation(float)<\/a><\/li>\n<\/ul>\n<p><a name=\"attr_android.support.design:fabSize\"><\/a><\/p>\n<h4 class=\"jd-details-title\">android.support.design:fabSize<\/h4>\n<p>Size for the FAB.<\/p>\n<p>Must be one of the following constant values.<\/p>\n<table width=\"1382\">\n<colgroup align=\"left\"><\/colgroup>\n<colgroup align=\"left\"><\/colgroup>\n<colgroup align=\"left\"><\/colgroup>\n<tbody>\n<tr class=\"firstRow\">\n<th>Constant<\/th>\n<th>Value<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><code>normal<\/code><\/td>\n<td>0<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><code>mini<\/code><\/td>\n<td>1<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This is a private symbol.<\/p>\n<h5 class=\"jd-tagtitle\">Related Methods<\/h5>\n<p><a name=\"attr_android.support.design:rippleColor\"><\/a><\/p>\n<h4 class=\"jd-details-title\">android.support.design:rippleColor<\/h4>\n<p>Ripple color for the FAB.<\/p>\n<p>Must be a color value, in the form of &#8220;<code>#<em>rgb<\/em><\/code>&#8220;, &#8220;<code>#<em>argb<\/em><\/code>&#8220;, &#8220;<code>#<em>rrggbb<\/em><\/code>&#8220;, or &#8220;<code>#<em>aarrggbb<\/em><\/code>&#8220;.<\/p>\n<p>This may also be a reference to a resource (in the form &#8220;<code>@[<em>package<\/em>:]<em>type<\/em>:<em>name<\/em><\/code>&#8220;) or theme attribute (in the form &#8220;<code>?[<em>package<\/em>:][<em>type<\/em>:]<em>name<\/em><\/code>&#8220;) containing a value of this type.<\/p>\n<p>This is a private symbol.<\/p>\n<h5 class=\"jd-tagtitle\">Related Methods<\/h5>\n<ul class=\"nolist list-paddingleft-2\">\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/support\/design\/widget\/FloatingActionButton.html#setRippleColor(int)\">setRippleColor(int)<\/a><\/li>\n<\/ul>\n<p><a name=\"attr_android.support.design:useCompatPadding\"><\/a><\/p>\n<h4 class=\"jd-details-title\">android.support.design:useCompatPadding<\/h4>\n<p>Enable compat padding.<\/p>\n<p>Must be a boolean value, either &#8220;<code>true<\/code>&#8221; or &#8220;<code>false<\/code>&#8220;.<\/p>\n<p>This may also be a reference to a resource (in the form &#8220;<code>@[<em>package<\/em>:]<em>type<\/em>:<em>name<\/em><\/code>&#8220;) or theme attribute (in the form &#8220;<code>?[<em>package<\/em>:][<em>type<\/em>:]<em>name<\/em><\/code>&#8220;) containing a value of this type.<\/p>\n<p>This is a private symbol.<\/p>\n<h5 class=\"jd-tagtitle\">Related Methods<\/h5>\n<ul class=\"nolist list-paddingleft-2\">\n<li><a href=\"http:\/\/developer.android.com\/reference\/android\/support\/design\/widget\/FloatingActionButton.html#setUseCompatPadding(boolean)\">setUseCompatPadding(boolean)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-146","post","type-post","status-publish","format-standard","hentry","category-android"],"_links":{"self":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=146"}],"version-history":[{"count":0,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/146\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}