2.Android Custom Generic Item layout

Source: Internet
Author: User

Reprint: Http://www.jianshu.com/p/e7ba4884dcddBaseItemLayout profile

Some of the following layouts are often encountered at work, marked red:


05.png
07.png
08.png

As a result, a generic item layout is customized so that you can add as many item as you want in just a few lines of code.

Use
    • Add Gradle Dependency

      Added in Build.gradle's dependencies

        dependencies {       ...       compile ‘com.maiml:baseitemlayoutlibrary:1.0.0‘  }
    • Use in layouts
 <com.maimlandroid:id= "@+id/layout" Android:layout_width= "match_parent" Android:layout_ Height= "wrap_content" app:text_size =  "app:text_color" = Span class= "hljs-string" > "@color/gray_333333" app:icon_margin_left =  "ten" app:item_height = Span class= "hljs-string" > "app:line_color" =  "@color/line_d6d6d6" > </ Com.maiml.library.baseitemlayout>           
    • Called in code
Layout = (baseitemlayout) Findviewbyid (r.id.layout); List<string> valueList =New Arraylist<> (); Valuelist.add ("album"); Valuelist.add ("Collection"); Valuelist.add ("Purse"); Valuelist.add ("Card package"); Valuelist.add ("Settings"); List<integer> residlist =new arraylist<> (); Residlist.add (R.DRAWABLE.XC); Residlist.add (R.drawable.sc); Residlist.add (R.DRAWABLE.QB); Residlist.add (R.DRAWABLE.KB); Residlist.add (R.DRAWABLE.SZ); Layout.setvaluelist (valueList) //text list. Setresidlist (residlist) //icon list setarrowresid (r.drawable.img_find_arrow) // Arrow on the right. Setarrowisshow (true) //whether the right arrow is displayed. Setitemmargintop ( Span class= "Hljs-number" >10) //set the item margin (all). Setitemmargintop ( 0,0) //set the margin for an item. Seticonheight (24) //the height of the icon. Seticonwidth (24" //the width of the icon. Create ();        
    • Setting Up Listener Events
    layout.setOnBaseItemClick(new BaseItemLayout.OnBaseItemClick() {            @Override            public void onItemClick(int position) { Log.e(TAG,"----- position = " + position); } });
Parameter description
name format Description
Text_size Integer Font size
Text_color Color Font Color
Icon_margin_left Integer The margin of the icon from the left
Icon_text_margin Integer Margin to the left of the text distance icon
Arrow_margin_right Integer Arrow from margin to right
Item_height Integer Height of item
Line_color Color The color of the line
Parametric plots
10.png Source Code

GitHub

2.Android Custom Generic Item layout

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.