E-commerce, Mall category app commonly used tags "hot"-third party open source--labelview

Source: Internet
Author: User

Labelview is an open source tag library on GitHub. Its Project homepage is: Https://github.com/linger1216//labelview
Labelview for a textview,imageview or a view returned by the adapter GetView in the ListView, add a label to the upper-left or upper-right corner

This demand design is more commonly used in marketplace apps and e-commerce apps, and the products displayed by these apps usually add some promotions or features of such products.
The Labelview is integrated from Android TextView and can be used as simple as the Android TextView using Labelview,labelview, as shown in the code:

Layout code:

1 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:orientation= "vertical"6 Tools:context= "Com.zzw.textlabelview.MainActivity" >7 8     <TextView9         Android:id= "@+id/textview1"Ten Android:layout_width= "Match_parent" One Android:layout_height= "Wrap_content" A Android:layout_weight= "1" - Android:background= "#90CAF9" - android:gravity= "Center" the Android:text= "TextView1" - android:textsize= "30SP" /> -  -     <TextView +         Android:id= "@+id/textview2" - Android:layout_width= "Match_parent" + Android:layout_height= "Wrap_content" A Android:layout_weight= "1" at Android:background= "#9FA8DA" - android:gravity= "Center" - Android:text= "TextView2" - android:textsize= "30SP" /> -  -     <ImageView in         Android:id= "@+id/imageview1" - Android:layout_width= "Match_parent" to Android:layout_height= "Wrap_content" + Android:layout_weight= "1" - android:src= "@drawable/ic_launcher" /> the  *     <ImageView $         Android:id= "@+id/imageview2"Panax Notoginseng Android:layout_width= "Match_parent" - Android:layout_height= "Wrap_content" the Android:layout_weight= "1" + Android:background= "#B39DDB" A android:src= "@drawable/ic_launcher" /> the  +   <View -         Android:id= "@+id/view"   $ Android:layout_width= "Match_parent"   $ Android:layout_height= "100dip"   - Android:background= "#e0e0e0" >   -     </View>   the  - </LinearLayout>

Java code:

1  PackageCom.zzw.textlabelview;2 3 ImportCom.lid.lib.LabelView;4 Importcom.lid.lib.LabelView.Gravity;5 6 Importandroid.app.Activity;7 ImportAndroid.graphics.Color;8 ImportAndroid.os.Bundle;9 ImportAndroid.view.View;Ten ImportAndroid.view.View.OnClickListener; One ImportAndroid.widget.Toast; A  -  Public classMainactivityextendsActivity { -  the @Override -     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); +  -         //add a label to the upper-left corner of TextView1 +LabelView Label1 =NewLabelView ( This); ALabel1.settext ("Hot"); atLabel1.setbackgroundcolor (0XFF03A9F4); -Label1.settargetview (Findviewbyid (R.id.textview1), 4, gravity.left_top); -  -         //add a label to the upper-right corner of the TEXTVIEW2 and click the label to remove -         FinalLabelView Label2 =NewLabelView ( This); -Label2.settext ("Click to remove"); inLabel2.setbackgroundcolor (0xffe91e63); -Label2.settargetview (Findviewbyid (R.ID.TEXTVIEW2), 20, to gravity.right_top); +Findviewbyid (R.ID.TEXTVIEW2). Setonclicklistener (NewOnclicklistener () { -  the @Override *              Public voidOnClick (View v) { $ Label2.remove ();Panax NotoginsengToast.maketext (Getapplicationcontext (), "tag removal succeeded", 0). Show (); -             } the         }); +  A         //Add a top left label for ImageView1, and customize the label word color theLabelView label3 =NewLabelView ( This); +Label3.settext ("Recommended"); - Label3.settextcolor (color.red); $Label3.setbackgroundcolor (0XFF03A9F4); $Label3.settargetview (Findviewbyid (r.id.imageview1), 10, - gravity.left_top); -  the         //Add a top-right label for IAMGEVIEW2 -LabelView Label4 =NewLabelView ( This);WuyiLabel4.settext ("Recommended"); theLabel4.setbackgroundcolor (0xffe91e63); -Label4.settargetview (Findviewbyid (R.ID.IMAGEVIEW2), 10, Wu gravity.right_top); -  About         //Add a top left label for a view (for ListView) $LabelView Label5 =NewLabelView ( This); -Label5.settext ("View"); - Label5.settextcolor (color.blue); -Label5.setbackgroundcolor (0xffe91e63); ALabel5.settargetview (Findviewbyid (R.id.view), 10, gravity.left_top); +     } the}

E-commerce, Mall category app commonly used tags "hot"-third party open source--labelview

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.