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

Android仿京東分類模塊左側(cè)分類條目效果

 更新時(shí)間:2018年02月11日 10:21:13   作者:siyadong1  
這篇文章主要為大家詳細(xì)介紹了Android仿京東分類模塊左側(cè)分類條目效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android仿京東左側(cè)分類條目效果的具體代碼,供大家參考,具體內(nèi)容如下

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.LinearLayout; 
import android.widget.ScrollView; 
import android.widget.TextView; 
 
import com.frame.R; 
 
import java.util.ArrayList; 
import java.util.List; 
 
/** 
 * Created by syd on 2016/10/9. 
 */ 
public class TestActivity extends Activity { 
 
 ScrollView sv_test; 
 LinearLayout ll_test_contain; 
 List<String> goodsList = new ArrayList<String>(); 
 List<TextView> textViewList = new ArrayList<>(); 
 List<View> viewList = new ArrayList<>(); 
 
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.test_activity_test); 
  initViews(); 
  initData(); 
 } 
 
 /** 
  * 初始化控件 
  */ 
 private void initViews() { 
  sv_test = (ScrollView) findViewById(R.id.sv_test); 
  ll_test_contain = (LinearLayout) findViewById(R.id.ll_test_contain); 
 } 
 
 protected void initData() { 
  goodsList.add("常用分類"); 
  goodsList.add("潮流女裝"); 
  goodsList.add("品牌男裝"); 
  goodsList.add("內(nèi)衣配飾"); 
  goodsList.add("家用電器"); 
  goodsList.add("手機(jī)數(shù)碼"); 
  goodsList.add("電腦辦公"); 
  goodsList.add("個(gè)護(hù)化妝"); 
  goodsList.add("母嬰頻道"); 
  goodsList.add("食物生鮮"); 
  goodsList.add("酒水飲料"); 
  goodsList.add("家居家紡"); 
  goodsList.add("酒水飲料"); 
  goodsList.add("整車車品"); 
  goodsList.add("運(yùn)動(dòng)戶外"); 
  goodsList.add("圖書(shū)"); 
  goodsList.add("鐘表"); 
  goodsList.add("居家生活"); 
  goodsList.add("珠寶飾品"); 
  goodsList.add("音像制品"); 
  goodsList.add("家具建材"); 
  goodsList.add("計(jì)生情趣"); 
  goodsList.add("營(yíng)養(yǎng)保健"); 
  goodsList.add("奢侈禮品"); 
  goodsList.add("生活服務(wù)"); 
  goodsList.add("旅游出行"); 
 
  //動(dòng)態(tài)生成每一個(gè)條目 
  for (int i = 0; i <goodsList.size() ; i++) { 
   View view = getLayoutInflater().inflate(R.layout.test_item_scrollview,null); 
   view.setOnClickListener(textOnClickListener); 
   TextView tv_item_scroll = (TextView) view.findViewById(R.id.tv_item_scroll); 
   view.setId(i); 
   tv_item_scroll.setText(goodsList.get(i)); 
   ll_test_contain.addView(view); 
   viewList.add(view); 
   textViewList.add(tv_item_scroll); 
  } 
 
  changeTextColor(0); 
 
 } 
 
 private View.OnClickListener textOnClickListener = new View.OnClickListener() { 
  @Override 
  public void onClick(View v) { 
 
   changeTextColor(v.getId()); 
   changeTextLocation(v.getId()); 
  } 
 }; 
 
 
  //改變點(diǎn)擊條目的位置,居中 
 private void changeTextLocation(int textPosition) { 
 
  int x = (viewList.get(textPosition).getTop() - sv_test.getHeight()/2 + (viewList.get(textPosition).getHeight() / 2)); 
  sv_test.smoothScrollTo(0, x); 
 
 } 
 
 //改變點(diǎn)擊條目的顏色 
 private void changeTextColor(int textPosition) { 
 
  for (int i = 0; i <textViewList.size() ; i++) { 
   textViewList.get(i).setTextColor(0xFF000000); 
   textViewList.get(i).setBackgroundColor(0x00000000); 
  } 
  textViewList.get(textPosition).setTextColor(0xFFFF0000); 
  textViewList.get(textPosition).setBackgroundColor(0xFFFFFFFF); 
 
 } 
 
} 

代碼2:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 android:orientation="vertical" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent"> 
 
<com.frame.activity.TestScrollView 
 android:id="@+id/sv_test" 
 android:layout_width="80dp" 
 android:layout_height="wrap_content"> 
 
 <LinearLayout 
  android:id="@+id/ll_test_contain" 
  android:orientation="vertical" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content"> 
 </LinearLayout> 
 
</com.frame.activity.TestScrollView> 
</LinearLayout> 

代碼3:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:orientation="vertical" android:layout_width="match_parent" 
 android:layout_height="match_parent">  
  
 <TextView 
  android:gravity="center" 
  android:paddingBottom="16dp" 
  android:paddingTop="16dp" 
  android:id="@+id/tv_item_scroll" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" /> 
 <ImageView 
  android:background="#cccccc" 
  android:layout_width="match_parent" 
  android:layout_height="1dp" /> 
  
</LinearLayout> 

效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

武乡县| 乐山市| 县级市| 塔城市| 封开县| 射洪县| 胶南市| 肇东市| 调兵山市| 图们市| 双城市| 贡山| 如皋市| 东山县| 溧阳市| 定兴县| 罗定市| 苏尼特左旗| 深州市| 凤凰县| 交城县| 郴州市| 晋城| 鹤壁市| 伊宁市| 台东县| 邛崃市| 晋中市| 济阳县| 柳州市| 皋兰县| 长岭县| 天峨县| 石家庄市| 察哈| 梨树县| 永春县| 岳西县| 金塔县| 宜宾县| 丁青县|