2017-02-01 2 views
0

Je ne suis pas en mesure d'utiliser l'effet d'entraînement en appuyant sur un onglet s'il vous plaît aider j'ai essayé beaucoup et lutter avec toute la journée.Comment puis-je utiliser l'effet d'entraînement sur les deux pré-sucette et sucette toute suggestion ?effet d'entraînement pour les onglets

MainActivity.java

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    mPager=(ViewPager)findViewById(R.id.pager); 
    mPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(),getApplicationContext())); 
    mTabs=(SlidingTabLayout)findViewById(R.id.tabs); 
    mTabs.setDistributeEvenly(true); 
    mTabs.setCustomTabView(R.layout.customtablayout,R.id.textTab); 
    mTabs.setBackgroundColor(getResources().getColor(R.color.colorAccent)); 
    mTabs.setSelectedIndicatorColors(getResources().getColor(R.color.colorPrimary)); 

    mTabs.setViewPager(mPager); 

} 

activitymain.xml

<sarveshchavan777.inrerface2.SlidingTabLayout 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" /> 

customtablayout.xml

<ImageView 
    android:id="@+id/imageTab" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" /> 

<TextView 
    android:id="@+id/textTab" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="bottom|center" /> 

Répondre

0

utiliser ce code pour tout élément que vous voulez donner effet d'entraînement.

Copiez ce code dans un nouveau fichier XML dans le dossier drawable. et définissez-le comme l'arrière-plan de tout élément pour lequel vous voulez un effet d'entraînement.

<?xml version="1.0" encoding="utf-8"?> 
    <ripple xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:color="@color/icons" 
    tools:targetApi="lollipop"> 
    <item android:drawable="?attr/colorPrimaryDark" /> 
</ripple