How to add a separator line for Android LinearLayout

Source: Internet
Author: User

Currently, there are two ways to know: 1, customize a view as a separator line, 2, use a higher version of the separator line properties

One, in the need to add a divider line, add a view, such as Imageview,textview, etc. can be, such as code, the key is to set the height is small, the width of the appropriate

< ImageView            Android:layout_width = "Fill_parent"           android:layout_height= "1DP"          android:background= "#00FF00"          />


Second, is to set the linearlayout of the separation line properties, parameter description:

The android:showdividers= "" Property has 4 values:None does not show the divider (default value);beginning the dividing line at the beginning;End Displays the divider line at the end;Middle display divider lines between each of the two components:In addition to setting the Android:showdividers property, you also set the Android:divider property, which represents the image of the divider line drawable (the height of the picture is the height of the divider, so thin

The code is as follows:

Android:showdividers= "End"  

You can also define a shape by yourself without a picture.

<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"> <sizeAndroid:width= "1DP" /> <SolidAndroid:color= "#0000FF00" /></Shape>

When you use it, just set the XML file as a picture android:divider.

How to add a separator line for Android LinearLayout

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.