2016-03-20 17 views
0

私はあるビューから別のアニメーションへの素早く変化するタブビューを実装しようとしており、現在のタブを強調表示しています。現在私が得ることのできるのは、機能する基本的なタブビューですが、タブの瞬時の切り替えや選択の強調表示はありません。私は私の活動のメインでその間Tabhostのアニメーション/選択肢がありません

package com.example.ex.test; 
public class MainActivity extends navBar { 
private FragmentTabHost mTabHost; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main2); 

    mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost); 
    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); 

    mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("Tab1"), 
      smithingTable.class, null); 
    mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("Tab2"), 
      smithingTable2.class, null); 
    mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("Tab3"), 
      Map.class, null); 
} 
} 

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TabWidget 
     android:id="@android:id/tabs" 

     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0"/> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_weight="0"/> 

    <FrameLayout 
     android:id="@+id/realtabcontent" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

</LinearLayout> 

例えばTAB1で

(TAB2は同じですが、わずかな変化で)ここに私の現在のコードです
<?xml version="1.0" encoding="utf-8"?> 
<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=".DeviceFragment" > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="test1" /> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imageView3" 
    android:layout_gravity="center_horizontal" 
    android:src="@drawable/newcomer_map" /> 

答えて

0

良い、私は私の独自の実装を作るために探していた間、私はページビュー/リスナー

1

マテリアルデザインタブを使用することをお勧めします。それは素晴らしいトランジションとはるかにカスタマイズ可能です。
はここで実装する方法のpost非常に良いことだ、それ

+0

を追加するために必要なことが判明 – user1519194

関連する問題