Xml layout content Summary (3) -- Android, xml -- android

Source: Internet
Author: User

Xml layout content Summary (3) -- Android, xml -- android

Border and border effects are often used in xml. Here we will summarize them.

3. border (border and border effect)

(1) right-angle border line



<LinearLayout
Android: layout_width = "200dp"
Android: layout_height = "30dp"
Android: layout_margin = "10dp"
Android: orientation = "vertical"
Android: background = "@ drawable/border_c"
>
</LinearLayout>

Border_c.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: android = "http://schemas.android.com/apk/res/android">
<! -- Fill color -->
<Solid android: color = "@ color/listitem_green"/>
<! -- Border width, color -->
<Stroke
Android: width = "0.1dp"
Android: color = "@ color/black"/>
<! -- Set the radians of four angles -->
<Corners
Android: topLeftRadius = "0.0dip"
Android: topRightRadius = "0.0dip"
Android: bottomLeftRadius = "0.0dip"
Android: bottomRightRadius = "0.0dip"
/>
</Shape>

(2) rounded border line



<LinearLayout
Android: layout_width = "200dp"
Android: layout_height = "30dp"
Android: layout_margin = "10dp"
Android: orientation = "vertical"
Android: background = "@ drawable/border_s"
>
</LinearLayout>

Border_s.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: android = "http://schemas.android.com/apk/res/android">
<! -- Fill color -->
<Solid android: color = "@ color/yellow"/>
<! -- Border width, color -->
<Stroke
Android: width = "0.1dp"
Android: color = "@ color/black"/>
<! -- Set the radians of four angles -->
<Corners
Android: topLeftRadius = "10.0dip"
Android: topRightRadius = "10.0dip"
Android: bottomLeftRadius = "10.0dip"
Android: bottomRightRadius = "10.0dip"
/>
</Shape>

(3) horizontal and vertical lines



<TextView
Android: layout_width = "200dp"
Android: layout_height = "0.5dp"
Android: background = "@ color/black"
/>
<TextView
Android: layout_marginTop = "10dp"
Android: layout_width = "0.5dp"
Android: layout_height = "50dp"
Android: background = "@ color/black"
/>

(4) button Effect

<Button
Android: id = "@ + id/button2"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_marginTop = "5dp"
Android: background = "@ drawable/btn_style_green"
Android: text = "Button"
Android: textColor = "@ color/white"
/>

Btn_style_green.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: android = "http://schemas.android.com/apk/res/android">

<Item android: drawable = "@ drawable/button_green_bg" android: state_pressed = "true"/>
<Item android: drawable = "@ drawable/button_blue_bg" android: state_focused = "false" android: state_pressed = "false"/>

</Selector>

Button_green_bg.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape
Xmlns: android = "http://schemas.android.com/apk/res/android">
<Solid android: color = "@ color/green"/>
<Stroke android: width = "0.5dip" android: color = "@ color/black"/>
<Corners android: topLeftRadius = "5.0dip" android: topRightRadius = "5.0dip" android: bottomLeftRadius = "5.0dip" android: bottomRightRadius = "5.0dip"/>
</Shape>


Button_blue_bg.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape
Xmlns: android = "http://schemas.android.com/apk/res/android">
<Solid android: color = "@ color/blue"/>
<Stroke android: width = "0.5dip" android: color = "@ color/black"/>
<Corners android: topLeftRadius = "5.0dip" android: topRightRadius = "5.0dip" android: bottomLeftRadius = "5.0dip" android: bottomRightRadius = "5.0dip"/>
</Shape>


Normal status: Click:



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.