Android Learning notes (1)

Source: Internet
Author: User
<span id="Label3"></p><p><p></p></p><p><p><span style="color: #3366ff;"><span style="font-size: 16px;">Content source: Gao Chengjing, Zhong "android Programming Classic case" study notes</span></span></p></p><p><p></p></p><p><p><span style="color: #008080;"><strong><span style="font-size: 16px;">Table Layout--tablelayout</span></strong></span></p></p><p><p><span style="font-size: 16px;">Table layouts manage the layout of the interface in rows and columns, but it is not possible to explicitly declare a few rows of columns. You can increase the row by TableRow and then add other controls to it</span></p></p><p><p><span style="font-size: 16px;">Common Properties for Tables:</span></p></p><p><p>Android:collapseclolumns---------hide the specified column</p></p><p><p>Android:shrinkcolumns:----------compress the specified columns</p></p><p><p>Android:stretchcolumns----------extension of the specified column</p></p><p><p>Android:layout_column-----------specifies the column where the control is located in the TableRow</p></p><p><p>Android:layout_span-------------specifies the number of columns that a control spans</p></p><p><p></p></p><p><p><span style="font-size: 14pt;"><strong><span style="color: #008080;">Custom Define Shape Type:</span></strong></span></p></p><p><p>Create a Rect.xml document:</p></p><pre><span style="color: #0000ff;"><span style="color: #0000ff;"><?</span></span><span style="color: #ff00ff;"><span style="color: #ff00ff;">XML version= "1.0" encoding= "utf-8"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">?></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Shape</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">xmlns:android</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "http://schemas.android.com/apk/res/android"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:shape</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "rectangle"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span>    <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Solid<br>    </span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:color</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "#00000000"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">/></span></span>    <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">padding<br></span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:left</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "5dp"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:top</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "5dp"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:right</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "5dp"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:bottom</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "5dp"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">/></span></span>    <span style="color: #0000ff;"><span style="color: #0000ff;"><</span></span><span style="color: #800000;"><span style="color: #800000;">Stroke</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:width</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "2dp"</span></span><span style="color: #ff0000;"><span style="color: #ff0000;">Android:color</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">= "#000000"</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">/></span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></</span></span><span style="color: #800000;"><span style="color: #800000;">Shape</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">></span></span></pre><p><p></p></p><p><p></p></p><p><p><span style="font-size: 14pt;"><strong><span style="color: #008080;">Horizontal screen Display:</span></strong></span></p></p><p><p>Method 1: Add android:screenorientation= "landscape" property to the activity in the Androidmanifestxml manifest file that requires a horizontal screen display</p></p><p><p>Method 2: make a judgment in the Code:</p></p><p><p>If (getrequestedorientation ()! = Activityinfo.screen_orientation_landscape)</p></p><p><p>{</p></p><p><p>Setrequestedorientation (activityinfo.orientation_landscape);</p></p><p><p>}</p></p><p><p></p></p><p><p><span style="font-size: 14pt;"><strong><span style="color: #008080;">Common properties in relative layout (relativelayout):</span></strong></span></p></p><p><p><span style="font-size: 16px;">Android:layout_centerhorizontal------sets whether the component is centered horizontally in the parent container</span></p></p><p><p><span style="font-size: 16px;">Android:layout_centervertical</span></p></p><p><p><span style="font-size: 16px;">Android:layout_centerinparent--------set whether the component is in the central location of the parent container</span></p></p><p><p>Android:layout_alignparenttop-------------sets whether the component aligns with the top of the parent container</p></p><p><p>Android:layout_alignparentbottom</p></p><p><p>Android:layout_alignparentleft</p></p><p><p>Android:layout_alignparentright</p></p><p><p>Android:layout_aligntop-------------------specifies that the component is above the control of the given ID</p></p><p><p>Android:layout_alignbottom</p></p><p><p>Android:layout_alignleft</p></p><p><p>Android:layout_alignright</p></p><p><p>Android:layout_torightof------------------specifies that the component is located on the right side of the control for the given ID</p></p><p><p>Android:layout_toleftof</p></p><p><p>Android:layout_above</p></p><p><p>Android:layout_below</p></p><p><p></p></p><p><p><span style="font-size: 14pt;"><strong><span style="color: #008080;">Frame Layout (framelayout):</span></strong></span></p></p><p><p><span style="font-size: 16px;">each control in a layout occupies a frame or layer on its own, and the portion of the layer that does not contain content is Transparent. The order in which the controls are added is the order of layer overlays,</span></p></p><p><p><span style="font-size: 16px;">The controls that are added later will overwrite the previous Control. The location of the control can be set through the properties of the Android:layout_grabity. Through the layer layout can</span></p></p><p><p><span style="font-size: 16px;">The effect of multiple control overlays or gradients is easy enough to implement</span></p></p><p><p></p></p><p><p><span style="color: #008080; font-size: 14pt;"><strong>About Timers Timer:</strong></span></p></p><p><p><span style="font-size: 16px;">The thread created by the timer belongs to a child thread and cannot be manipulated directly by the Ui. The interface operation in Android is Non-thread safe, that is, when multiple threads</span></p></p><p><p><span style="font-size: 16px;">The knots may not be consistent when operating. To avoid this, Android specifies that all UI actions can only be placed in the main thread.</span></p></p><p><p></p></p><p><p><span style="font-size: 14pt;"><strong><span style="color: #008080;">Handler message Delivery:</span></strong></span></p></p><p><p><span style="font-size: 16px;">Handler can provide message delivery for communication between threads and, when Handler sends a successful message, calls the handler Class's</span></p></p><p><p><span style="font-size: 16px;">Handlemessage (Message Msg) method; The main methods of the handler class Are:</span></p></p><p><p><span style="font-size: 16px;">public void Handlemessage (message Msg);//---get and process information</span></p></p><p><p><span style="font-size: 16px;">Public Final Boolean sendemptymessage (int);//---send a message that contains only flags</span></p></p><p><p><span style="font-size: 16px;">Public final Boolean hasmessage (int);//---monitor Message Queuing for flagged messages</span></p></p><p><p><span style="font-size: 16px;">Public Final Boolean post (runable R);----add a thread to the message queue</span></p></p><p><p></p></p><p><p><span style="font-size: 14pt;"><strong><span style="color: #008080;">Message class:</span></strong></span></p></p><p><p><span style="font-size: 16px;">Public Message ();//---construction method, recommended to use Message.obtain ();</span></p></p><p><p><span style="font-size: 16px;">public void CopyFrom (Message msg);//---copy the specified content</span></p></p><p><p><span style="font-size: 16px;">Public long Getwhen ();//---gets The time the message was sent, in MS</span></p></p><p><p><span style="font-size: 16px;">Public Bundle GetData ();//---get the data in the message</span></p></p><p><p><span style="font-size: 16px;">public static message obtain ();//---get a message from the message pool</span></p></p><p><p><span style="font-size: 16px;">public void SetData (Bundle data);//---writing data to the message</span></p></p><p><p><span style="font-size: 16px;">public void Settarget (Handler Target).//---set The target object of the message</span></p></p><p><p></p></p><p><p>Android Learning notes (1)</p></p></span>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.