最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

開源電商app常用標(biāo)簽"hot"之第三方開源LabelView

 更新時間:2015年12月07日 11:34:47   作者:Z2  
這篇文章主要介紹了開源電商app常用標(biāo)簽"hot"之第三方開源LabelView,對開源電商app相關(guān)資料感興趣的朋友一起學(xué)習(xí)吧

先給大家展示下效果圖,看看是不是在你的意料之中哈。

LabelView是在github上一個開源的標(biāo)簽庫。其項目主頁是:https://github.com/linger1216//labelview
LabelView為一個TextView,ImageView或者為ListView中適配器getView返回的View,增加一個左上角或者右上角的標(biāo)簽

這種需求設(shè)計在商城類APP、電商類APP中比較常用,這些APP展示的商品,通常會增加一些促銷或者該類商品的特征。
LabelView集成自Android TextView,可以像使用Android TextView一樣使用LabelView,LabelView使用簡單,如代碼所示:

布局代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   tools:context="com.zzw.textlabelview.MainActivity" >
   <TextView
     android:id="@+id/textView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight=""
     android:background="#CAF"
     android:gravity="center"
     android:text="textView"
     android:textSize="sp" />
   <TextView
     android:id="@+id/textView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight=""
     android:background="#FADA"
     android:gravity="center"
     android:text="textView"
     android:textSize="sp" />
   <ImageView
     android:id="@+id/imageView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight=""
     android:src="@drawable/ic_launcher" />
   <ImageView
     android:id="@+id/imageView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight=""
     android:background="#BDDB"
     android:src="@drawable/ic_launcher" />
  <View 
     android:id="@+id/view" 
     android:layout_width="match_parent" 
     android:layout_height="dip" 
     android:background="#eee" > 
   </View> 
 </LinearLayout> 

JAVA代碼:

 package com.zzw.textlabelview;
 import com.lid.lib.LabelView;
 import com.lid.lib.LabelView.Gravity;
 import android.app.Activity;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Toast;
 public class MainActivity extends Activity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
     //為TextView左上角添加一個標(biāo)簽
     LabelView label = new LabelView(this);
     label.setText("Hot");
     label.setBackgroundColor(xffaf);
     label.setTargetView(findViewById(R.id.textView), , Gravity.LEFT_TOP);
     //為TextView右上角添加一個標(biāo)簽,點擊標(biāo)簽移除
     final LabelView label = new LabelView(this);
     label.setText("點擊移除");
     label.setBackgroundColor(xffEE);
     label.setTargetView(findViewById(R.id.textView), ,
         Gravity.RIGHT_TOP);
     findViewById(R.id.textView).setOnClickListener(new OnClickListener() {
       @Override
       public void onClick(View v) {
         label.remove();
         Toast.makeText(getApplicationContext(), "標(biāo)簽移除成功", ).show();
       }
     });
     //為ImageView添加一個左上角標(biāo)簽,并且自定義標(biāo)簽字顏色
     LabelView label = new LabelView(this);
     label.setText("推薦");
     label.setTextColor(Color.RED);
     label.setBackgroundColor(xffaf);
     label.setTargetView(findViewById(R.id.imageView), ,
         Gravity.LEFT_TOP);
     //為IamgeView添加一個右上角標(biāo)簽
     LabelView label = new LabelView(this);
     label.setText("推薦");
     label.setBackgroundColor(xffEE);
     label.setTargetView(findViewById(R.id.imageView), ,
         Gravity.RIGHT_TOP);
     //為一個View添加一個左上角標(biāo)簽(ListView用)
     LabelView label = new LabelView(this);
     label.setText("view");
     label.setTextColor(Color.BLUE);
     label.setBackgroundColor(xffEE);
     label.setTargetView(findViewById(R.id.view), , Gravity.LEFT_TOP);
   }
 }

以上內(nèi)容是本文給大家分享的開源電商app常用標(biāo)簽"hot"之第三方開源LabelView,希望大家喜歡。

相關(guān)文章

最新評論

华蓥市| 高邑县| 岳阳市| 哈巴河县| 尼木县| 龙门县| 临城县| 个旧市| 达州市| 阿拉善盟| 太白县| 临汾市| 田阳县| SHOW| 汝南县| 同德县| 高清| 巴南区| 黄冈市| 广西| 安新县| 寿宁县| 平度市| 广州市| 金阳县| 八宿县| 岐山县| 应城市| 苍溪县| 托克逊县| 江达县| 诏安县| 莱阳市| 石楼县| 出国| 吴堡县| 宁明县| 新巴尔虎右旗| 新乐市| 昌邑市| 广南县|