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.