Android uses XML to implement split line _android

Source: Internet
Author: User

Because there is no art, so you can only do it yourself.

XML written in the layout folder

Method 1: Add the above code to the layout XML file inside the layout

 <view
 android:layout_width= "match_parent"
 android:layout_height= "1DP"
 android:background= "@ Color/orange_normal "/>

Effect chart

Draw lines with shape line or rectangle in the Drawable folder

Method 2: Create a new XML with shape in drawable

And then quote in the layout file in layout.

This method can refer to the same line style multiple places

<!--drawable/line_my.xml-->
<shape xmlns:android= "Http://schemas.android.com/apk/res/android"
 android:shape= "line" >

 <stroke android:color= "@color/orange_normal"/>

</shape>

Or with a filled rectangle.

<shape xmlns:android= "http://schemas.android.com/apk/res/android"
 android:shape= "Rectangle" >

 < Solid android:color= "@color/orange_normal"/>

 <size android:height= "
  1dp"
  android:width= "100DP" />

</shape>

Note
Android:width= "100DP" cannot be assigned the value "Match_parent"
Quote in Layout/bomb_fragment.xml

 <textview
   android:layout_width= "match_parent"
   android:layout_height= "Wrap_content"
   android: background= "@drawable/line_my"/>

I hope this article will help you learn about Android software programming.

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.