Common tags for e-commerce and mall apps & quot; hot & quot; -- third-party open source -- LabelView, APP -- labelview

Source: Internet
Author: User

Common tags for e-commerce and mall apps: "hot" -- third-party open source -- LabelView and APP -- labelview

 

LabelView is an open-source tag library on github. Its project home page is: https://github.com/linger1216//labelview
LabelView is a TextView, ImageView, or View returned by the adapter getView in ListView. Add a label in the upper left or upper right corner.

This kind of requirement design is commonly used in mall apps and E-Commerce apps. The products displayed by these apps usually increase the features of promotions or such products.
LabelView is integrated from Android TextView. You can use LabelView like Android TextView. LabelView is easy to use, as shown in the Code:

 

Layout code:

 1 <LinearLayout xmlns: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     <TextView 9         android:id="@+id/textView1"10         android:layout_width="match_parent"11         android:layout_height="wrap_content"12         android:layout_weight="1"13         android:background="#90CAF9"14         android:gravity="center"15         android:text="textView1"16         android:textSize="30sp" />17 18     <TextView19         android:id="@+id/textView2"20         android:layout_width="match_parent"21         android:layout_height="wrap_content"22         android:layout_weight="1"23         android:background="#9FA8DA"24         android:gravity="center"25         android:text="textView2"26         android:textSize="30sp" />27 28     <ImageView29         android:id="@+id/imageView1"30         android:layout_width="match_parent"31         android:layout_height="wrap_content"32         android:layout_weight="1"33         android:src="@drawable/ic_launcher" />34 35     <ImageView36         android:id="@+id/imageView2"37         android:layout_width="match_parent"38         android:layout_height="wrap_content"39         android:layout_weight="1"40         android:background="#B39DDB"41         android:src="@drawable/ic_launcher" />42 43   <View  44         android:id="@+id/view"  45         android:layout_width="match_parent"  46         android:layout_height="100dip"  47         android:background="#e0e0e0" >  48     </View>  49 50 </LinearLayout>

 

JAVA code:

1 package com. zzw. textlabelview; 2 3 import com. lid. lib. labelView; 4 import com. lid. lib. labelView. gravity; 5 6 import android. app. activity; 7 import android. graphics. color; 8 import android. OS. bundle; 9 import android. view. view; 10 import android. view. view. onClickListener; 11 import android. widget. toast; 12 13 public class MainActivity extends Activity {14 15 @ Override16 protected void onCreate (Bundle savedInstanceState) {17 super. onCreate (savedInstanceState); 18 setContentView (R. layout. activity_main); 19 20 // Add a label 21 LabelView label1 = new LabelView (this); 22 label1.setText ("Hot"); 23 label1.setBackgroundColor (0xff03a9f4) to the top left corner of TextView1 ); 24 label1.setTargetView (findViewById (R. id. textView1), 4, Gravity. LEFT_TOP); 25 26 // Add a label to the top right corner of TextView2, click the label to remove 27 final LabelView label2 = new LabelView (this); 28 label2.setText ("click to remove "); 29 label2.setBackgroundColor (0xffE91E63); 30 label2.setTargetView (findViewById (R. id. textView2), 20,31 Gravity. RIGHT_TOP); 32 findViewById (R. id. textView2 ). setOnClickListener (new OnClickListener () {33 34 @ Override35 public void onClick (View v) {36 label2.remove (); 37 Toast. makeText (getApplicationContext (), "tag removed successfully", 0 ). show (); 38} 39}); 40 41 // Add a label in the upper left corner of ImageView1 and customize the label word color 42 LabelView label3 = new LabelView (this ); 43 label3.setText ("recommended"); 44 label3.setTextColor (Color. RED); 45 label3.setBackgroundColor (0xff03a9f4); 46 label3.setTargetView (findViewById (R. id. imageView1), 10, 47 Gravity. LEFT_TOP); 48 49 // Add a label 50 LabelView label4 = new LabelView (this); 51 label4.setText ("recommended"); 52 label4.setBackgroundColor (0xffE91E63) to IamgeView2 ); 53 label4.setTargetView (findViewById (R. id. imageView2), 10, 54 Gravity. RIGHT_TOP); 55 56 // Add a label in the upper left corner for a View (for ListView) 57 LabelView label5 = new LabelView (this); 58 label5.setText ("view "); 59 label5.setTextColor (Color. BLUE); 60 label5.setBackgroundColor (0xffE91E63); 61 label5.setTargetView (findViewById (R. id. view), 10, Gravity. LEFT_TOP); 62} 63}

 

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.