欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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("圖書"); 
  goodsList.add("鐘表"); 
  goodsList.add("居家生活"); 
  goodsList.add("珠寶飾品"); 
  goodsList.add("音像制品"); 
  goodsList.add("家具建材"); 
  goodsList.add("計(jì)生情趣"); 
  goodsList.add("營養(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> 

效果圖:

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

相關(guān)文章

  • android自定義AlertDialog對話框

    android自定義AlertDialog對話框

    這篇文章主要為大家詳細(xì)介紹了android自定義AlertDialog的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 使用Glide實(shí)現(xiàn)高斯模糊效果

    使用Glide實(shí)現(xiàn)高斯模糊效果

    這篇文章主要為大家詳細(xì)介紹了使用Glide實(shí)現(xiàn)高斯模糊效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-12-12
  • Android Canvas方法總結(jié)最全面詳解API(小結(jié))

    Android Canvas方法總結(jié)最全面詳解API(小結(jié))

    本篇文章主要介紹了Android Canvas方法總結(jié)最全面詳解API(小結(jié)),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11
  • Android編程之藍(lán)牙測試實(shí)例

    Android編程之藍(lán)牙測試實(shí)例

    這篇文章主要介紹了Android編程之藍(lán)牙測試,較為詳細(xì)的分析了Android藍(lán)牙測試的相關(guān)運(yùn)行環(huán)境與調(diào)試技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-04-04
  • 關(guān)于android studio通過命令行運(yùn)行g(shù)radle編譯命令的問題

    關(guān)于android studio通過命令行運(yùn)行g(shù)radle編譯命令的問題

    這篇文章主要介紹了關(guān)于android studio通過命令行運(yùn)行g(shù)radle編譯命令的問題,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-11-11
  • 解決Android Studio Design界面不顯示layout控件的問題

    解決Android Studio Design界面不顯示layout控件的問題

    這篇文章主要介紹了解決Android Studio Design界面不顯示layout控件的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Flutter?GetX使用實(shí)例詳細(xì)解讀

    Flutter?GetX使用實(shí)例詳細(xì)解讀

    這篇文章主要為大家介紹了Flutter?GetX使用示例詳細(xì)解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-04-04
  • Android源碼中final關(guān)鍵字的用法及final,finally,finalize的區(qū)別

    Android源碼中final關(guān)鍵字的用法及final,finally,finalize的區(qū)別

    Android的源碼中很多地方對final關(guān)鍵字的用法很是“別出心裁”,之所以這么說是因?yàn)槲覐臎]看過是這么使用final關(guān)鍵字的,通過本文給大家分享Android源碼中final關(guān)鍵字的用法及final,finally,finalize的區(qū)別,感興趣的朋友一起學(xué)習(xí)吧
    2015-12-12
  • Android App調(diào)試內(nèi)存泄露之Cursor篇

    Android App調(diào)試內(nèi)存泄露之Cursor篇

    最近在工作中處理了一些內(nèi)存泄露的問題,在這個(gè)過程中我尤其發(fā)現(xiàn)了一些基本的問題反而忽略導(dǎo)致內(nèi)存泄露
    2012-11-11
  • Gradle的安裝和環(huán)境變量的配置詳解

    Gradle的安裝和環(huán)境變量的配置詳解

    這篇文章主要介紹了Gradle的安裝和環(huán)境變量的配置詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07

最新評論