Android Logistics Tracking

Source: Internet
Author: User

Recently on the Internet to see the layout effect of the timeline, try to follow this principle, to achieve the effect of logistics tracking, has been achieved, the effect of such as.



The layout of the interface is mainly implemented by the ListView, and the ListView item is left and right. On the left is a vertical bar, state picture, vertical bar. On the right is logistics information and time.

Start the left line height is not good fit, finally consulted netizens, with the Layout_weight attribute.

The vertical line is used ImageView display, the result lines of the height of the smaller, the width is also smaller, causing the screen to see the left side of the layout of the status picture on the line.

Finally, the use of the view to draw a vertical line, the effect is quite ideal amount.

The specific layout is as follows:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" Wrap_content "android:orientation = "Horizontal" > <linearlayout android:layout_width= "wrap_content" android:layout_height= "f       Ill_parent "android:layout_marginstart=" 10dip "android:orientation=" vertical "android:gravity=" center " > <view android:id= "@+id/view_logistic_tracking_line1" android:layout_width= "2d IP "android:layout_height=" 20dip "android:background=" #DCDCDC "/> <imageview android:i D= "@+id/mgview_logistic_tracking_status" android:layout_width= "wrap_content" android:layout_height= "WR             Ap_content "android:src=" @drawable/logistics_state1 "android:contentdescription=" @string/app_name "/>         <view    Android:id= "@+id/view_logistic_tracking_line2" android:layout_width= "2dip" Android:layout_heig ht= "0dip" android:layout_weight= "1" android:background= "#DCDCDC"/> </LinearLayout> < LinearLayout android:id= "@+id/ll_logistic_tracking_timeline" android:layout_width= "Fill_parent" Andro id:layout_height= "Wrap_content" android:layout_marginleft= "10dip" android:layout_marginright= "10dip" and            roid:orientation= "vertical" > <textview android:id= "@+id/tv_logistic_tracking_address" Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_margintop              = "20dip" android:textsize= "20sp" android:textcolor= "#000000"/> <textview Android:id= "@+id/tv_logistic_tracking_time" android:layout_width= "Match_parent" Android:layout_   height= "Wrap_content"     android:layout_margintop= "10dip" android:layout_marginbottom= "20dip" android:textsize= "18SP" and Roid:textcolor= "#000000"/> </LinearLayout> </LinearLayout>


Custom adapters:

public class Timelineadapter extends Baseadapter {private Context mcontext=null; Private list<timeline> mlist=null;private layoutinflater minflater;public timelineadapter (context context, List <TimeLine> list) {This.mcontext = Context;minflater = Layoutinflater.from (context); mlist = list;} @Overridepublic int GetCount () {//TODO auto-generated method stubif (null!=mlist) {return mlist.size ();} return 0;} @Overridepublic Object getItem (int position) {//TODO auto-generated method stubif (null!=mlist) {return Mlist.get ( position); }return null;} @Overridepublic long Getitemid (int position) {//TODO auto-generated method Stubreturn position;} @SuppressLint ("Inflateparams") @Overridepublic view GetView (int position, view Convertview, ViewGroup parent) {//TODO auto-generated method Stub Viewhold viewhold;if (Convertview = = null) {Viewhold = new viewhold (); Convertview = minflater.in Flate (R.layout.timeline_item, null); Viewhold.imageview1 = (ImageView) Convertview.findviewbyid (R.id.mgvieW_logistic_tracking_status); viewhold.textview1 = (TextView) Convertview.findviewbyid (r.id.tv_logistic_tracking_ address); viewhold.textview2 = (TextView) Convertview.findviewbyid (r.id.tv_logistic_tracking_time); viewhold.line1 = (View) Convertview.findviewbyid (r.id.view_logistic_tracking_line1); Convertview.settag (viewHold);} else {viewhold = (viewhold) Convertview.gettag ();} if (position==0) {viewHold.line1.setVisibility (view.invisible); ViewHold.imageView1.setImageResource ( R.drawable.logistics_state);} Else{viewhold.line1.setvisibility (view.visible); ViewHold.imageView1.setImageResource (R.drawable.logistics_ STATE1);} ViewHold.textView1.setText (Mlist.get (position). Getmaddress ()); ViewHold.textView2.setText (Mlist.get (position).    Getmtime ()); return Convertview;}        Private final static class viewhold{ImageView ImageView1;    View line1;    TextView TextView1;      TextView TextView2; }}

Timeline definition:

public class TimeLine {private string  maddress;private string  mtime;public TimeLine (string address, string time {this.maddress = Address;this.mtime = time;} Public String getmaddress () {return maddress;} public void setmaddress (String maddress) {this.maddress = maddress;} Public String Getmtime () {return mtime;} public void Setmtime (String mtime) {this.mtime = Mtime;}}




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Logistics Tracking

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.