XML layout skills

Source: Internet
Author: User

PostInvalidate (); interface refresh
 

A list element may be 48px by default.
Android: visibility = "invisible"> set the component to show visible, not to show invisible, and disappear gone.
Android: background = "@ null" sets no background for components
Android: layout_gravity = "right | center_vertical" right and vertical center
<Button

Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: drawableTop = "@ drawable/star": Set the image above the button
Android: text = "button 1"
/>

 
<Include
Android: id = "@ + id/vip_include_top"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: layout_alignParentTop = "true"
Layout = "@ layout/top_1"/> contains
<SlidingDrawer
Android: id = "@ + id/sliding"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: content = "@ + id/allApps"
Android: handle = "@ + id/imageViewIcon"
Ndroid: orientation = "vertical"
> Content (Class-level control) handle must be set for drawer design)
Android: layout_alignParentBottom = "true" is always at the bottom of the parent Element
Android: scrollbars = "none" Do not scroll bars
Android: gravity: For the view control, it is used to set the position where the view text should be displayed. The default value is left.

Android: layout_gravity: relative to the parent element containing the modified element, set the location of the element in the parent element.
<Button android: layout_width = "120dip"
Android: layout_height = "wrap_content"
Android: text = "switching program"
Style = "@ android: style/ButtonBar" sets the button to the style of the button bar.
Android: id = "@ + id/btn7"
Android: layout_weight = "1"/>
 

RequestWindowFeature (Window. FEATURE_NO_TITLE); set no title
Add android: theme = "@ android: style/Theme. NoTitleBar" to the application tag to remove the title bar of all Activity interfaces.
Modify AndroidManifest. xml
This. getWindow (). setFlags (WindowManager. LayoutParams. FLAG_FULLSCREEN, WindowManager. LayoutParams. FLAG_FULLSCREEN); set full screen
<Resources>
<Style name = "tab_btn">
<Item name = "android: textAppearance"> @ style/tab_item_text_style </item>
<Item name = "android: gravity"> center_horizontal </item>
<Item name = "android: background"> @ drawable/trans </item>
<Item name = "android: layout_width"> 0.0dip </item>
<Item name = "android: layout_height"> wrap_content </item>
<Item name = "android: button"> @ null </item>
<Item name = "android: layout_weight"> 1.0 </item> the Style attribute of the Custom button
</Style>
</Resources>

<Selector xmlns: android = "http://schemas.android.com/apk/res/android">
<Item android: state_enabled = "false" android: drawable = "@ drawable/input_normal"/>
<Item android: state_pressed = "true" android: drawable = "@ drawable/input_normal"/>
<Item android: state_focused = "true" android: drawable = "@ drawable/input_over"/>
</Selector> define the component to get the focus. Click to activate the component.

<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: android = "http://schemas.android.com/apk/res/android">
<Gradient
Android: startColor = "# FFFFFF"
Android: endColor = "#000000"
Android: angle = "270"/> </shape>: Set the Drawable gradient.
SetBackgroundResource (R. drawable. bg); call

// Set the Gallery style in the getView of BaseAdapter.

TypedArray typedArray = context. obtainStyledAttributes (R. styleable. Gallery );
ImageView. setBackgroundResource (typedArray. getResourceId (R. styleable. Gallery_android_galleryItemBackground, 0 ));
Return imageView;
Android: spacing = "10dp" // Gallery Interval
 
Class 1: the property value is true or false.
 

Android: layout_centerHrizontal? Horizontal Center
Android: layout_centerVertical ?? Vertical center
Android: layout_centerInparent ??? Completely centered relative to the parent Element
Android: layout_alignParentBottom: attach the lower edge of the parent Element
Android: layout_alignParentLeft ?? Attach the left edge of the parent Element
Android: layout_alignParentRight? Attach the right edge of the parent Element
Android: layout_alignParentTop ??? Attach the upper edge of the parent Element
Android: layout_alignWithParentIfMissing? If the corresponding sibling element cannot be found, the parent element will be used as a reference object.
Class 2: the property value must be the reference name of the id"
Android: layout_below ????? Below an element
Android: layout_above ????? Above an element
Android: layout_toLeftOf ?? On the left of an element
Android: layout_toRightOf? On the Right of an element
Android: layout_alignTop ?? The top edge of the element is aligned with the top edge of an element.
Android: layout_alignLeft? The left edge of the element is aligned with the left edge of an element.
Android: layout_alignBottom: the bottom edge of the current element is aligned with the bottom edge of an element.
Android: layout_alignRight? The right edge of the element is aligned with the right edge of an element.
Category 3: attribute values are specific pixel values, such as 30dip and 40px.
Android: layout_marginBottom ?????? Distance from the bottom edge of an element
Android: layout_marginLeft ???????? Distance from the left edge of an element
Android: layout_marginRight ??????? Distance from the right edge of an element
Android: layout_marginTop ????????? Distance from the edge of an element
 
Android: scaleType: android: scaleType controls how images are resized/moved to match the size of ImageView.
ImageView. ScaleType/android: the differences between scaleType values:
CENTER/center? Centered by the original size of the image. When the length/width of the image exceeds the length/width of the View, the center part of the screenshot is displayed.
CENTER_CROP/centerCrop? Scale up the image size in the center so that the image length (width) is equal to or greater than the View length (width)
CENTER_INSIDE/centerInside? The image content is displayed in the center. The image length/width is equal to or less than the View length/width by scale down or by the original size.
FIT_CENTER/fitCenter? Scale up or down an image to the width of the View in proportion and display it in the center.
FIT_END/fitEnd ?? Scale up or down an image to the width of the View, and display it in the lower part of the View.
FIT_START/fitStart? Scale up/down an image proportionally to the width of the View, and display it in the top part of the View.
FIT_XY/fitXY? Scale up or down an image proportionally to the size of the View display MATRIX/matrix, and dynamically zoom in and zoom in the image to display it.
** Note that the names of images in the Drawable folder cannot be capitalized.

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.