Android about button Gradient background color of the detailed, excerpt
Source: Internet
Author: User
<span id="Label3"></p>Use of shape in Android (android:angle Pee)<span class="kind"><span class="kind">category: Mobile Dev <span class="kind">/Android<span class="kind">/articles</span> </span> </span></span><p><p>This document references http://kofi1122.blog.51cto.com/2815761/521605 and http://blog.csdn.net/qizi329/article/details/6309819</p></p><p><p></p></p><p><shape><br><!--solid--<br><solid android:color= "#ff9d77"/><br><!--gradients--<br><gradient<br>Android:startcolor= "#ff8c00"<br>Android:endcolor= "#FFFFFF"<br>Android:angle= "/>"<br><!--strokes--<br><stroke<br>Android:width= "2dp"<br>Android:color= "#dcdcdc"/><br><!--rounded corners--<br><corners<br>android:radius= "2dp"/><br><padding<br>android:left= "10dp"<br>android:top= "10dp"<br>android:right= "10dp"<br>Android:bottom= "10dp"/><br></shape></p><p><p>Solid: filled is the meaning of filling<br>ANDROID:COLOR Specifies the color of the fill<br><br>Gradient: Gradient<br>Android:startcolor and Android:endcolor are start and end colors respectively, android:angle is the gradient angle and must be an integer multiple of 45.<br>In addition, the default mode of the gradient is android:type= "linear", that is, linear gradient, you can specify the gradient to radial gradient, android:type= "radial", radial gradient needs to specify the radius android:gradientradius= "50".</p></p><p><p>Android:angle Online There are various statements, here, I say that their experimental results, gradient, the most primitive, that is, android:angle= "0" when it is from left to right, according to the beginning color to the end color to render, android:angle= "90" is from the bottom to the rendering, android:angle= "270" is from the top to down rendering, android:angle= "180" is from right to left to render, android:angle= "360" and android:angle= "0" is the same, So here it should be, in the rendering of the most primitive rendering Swatch (the control inside as a piece can be rotated around the center of the Board) around the center of the control to rotate the corresponding degree, that is, the value inside the android:angle is the angle of rotation required, but this angle of rotation must be 45 integer times</p></p><p><br>Stroke: Stroke<br>Android:width= the width of the "2dp" stroke, android:color the color of the Stroke.<br>We can also make the stroke into a dashed form, set in the following way:<br>Android:dashwidth= "5dp"<br>android:dashgap= "3dp"<br>Where android:dashwidth represents the width of a horizontal line such as '-', Android:dashgap represents the distance between Them.<br><br>Corners: rounded Corners<br>The Android:radius is the radian of the angle, and the larger the value the greater the Rounded.<br>We can also set the four angles to different angles by:<br><corners<br>android:toprightradius= "20dp" Upper right corner<br>android:bottomleftradius= "20dp" lower right corner<br>android:topleftradius= "1dp" Upper left corner<br>android:bottomrightradius= "0dp" Lower left corner<br>/><br>Here is a place to note that the Bottomleftradius is the lower right corner, not the lower left corner, this should not be Mistaken.<br>There are also online to see someone said set to 0DP invalid, but I found in the test is ok, I use 2.2, may fix the problem, if it is invalid, it can only be set to 1dp.<br><br>Padding: interval<br>The spacing between the middle text distance border.<br><br><br>This is generally the case, the following is a<strong><strong>Use</strong></strong>Specific example: Use the background of the button in the selector, define the general state of the buttons, get the focus state and the state when pressed, the specific code is as Follows:<br><br>Main.xml:<br><button<br>Android:layout_width= "wrap_content"<br>android:layout_height= "wrap_content"<br>android:text= "testshapebutton"<br>Android:background= "@drawable/button_selector"<br>/><br><br>Button_selector.xml:<br><?xml version= "1.0" encoding= "utf-8"?><br><selector<br>Xmlns:android= "http://schemas.android.com/apk/res/android" ><br><item android:state_pressed= "true" ><br><shape><br><!--gradients--<br><gradient<br>Android:startcolor= "#ff8c00"<br>Android:endcolor= "#FFFFFF"<br>Android:type= "radial"<br>android:gradientradius= "/>"<br><!--strokes--<br><stroke<br>Android:width= "2dp"<br>Android:color= "#dcdcdc"<br>Android:dashwidth= "5dp"<br>android:dashgap= "3dp"/><br><!--rounded corners--<br><corners<br>android:radius= "2dp"/><br><padding<br>android:left= "10dp"<br>android:top= "10dp"<br>android:right= "10dp"<br>Android:bottom= "10dp"/><br></shape><br></item><br><br><item android:state_focused= "true" ><br><shape><br><gradient<br>Android:startcolor= "#ffc2b7"<br>Android:endcolor= "#ffc2b7"<br>Android:angle= "/>"<br><stroke<br>Android:width= "2dp"<br>Android:color= "#dcdcdc"/><br><corners<br>android:radius= "2dp"/><br><padding<br>android:left= "10dp"<br>android:top= "10dp"<br>android:right= "10dp"<br>Android:bottom= "10dp"/><br></shape><br></item><br><br><item><br><shape><br><solid android:color= "#ff9d77"/><br><stroke<br>Android:width= "2dp"<br>Android:color= "#fad3cf"/><br><corners<br>android:toprightradius= "5dp"<br>android:bottomleftradius= "5dp"<br>android:topleftradius= "0dp"<br>android:bottomrightradius= "0dp"<br>/><br><padding<br>android:left= "10dp"<br>android:top= "10dp"<br>android:right= "10dp"<br>Android:bottom= "10dp"/><br></shape><br></item><br></selector></p><p><p>Operating effects such as:</p></p><p><p>General Status:</p></p><p><p></p></p><p><p></p></p><p><p>Get Focus Status:</p></p><p><p></p></p><p><p></p></p><p><p>Press the Status:</p></p>Original Link: http://www.verydemo.com/demo_c131_i26235.html<p><p>Android about button Gradient background color of the detailed, excerpt</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service