下の画像のようにTabBarを作成したい:
ここでは、すべてのタブ バーが正常です。ただ彼らはカスタムメイドです。上の画像のようにタブバーを作成したいと思います。中央のタブが上がっています。
それで、それを可能にするために私は何をしなければなりませんか?
デモがあれば、それは良いでしょう。
私を助けてください。
下の画像のようにTabBarを作成したい:
ここでは、すべてのタブ バーが正常です。ただ彼らはカスタムメイドです。上の画像のようにタブバーを作成したいと思います。中央のタブが上がっています。
それで、それを可能にするために私は何をしなければなりませんか?
デモがあれば、それは良いでしょう。
私を助けてください。
タブウィジェットの背景画像を次のように設定できます
tabHost.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.home_h);
tabHost.getTabWidget().getChildAt(1).setBackgroundResource(R.drawable.live);
tabHost.getTabWidget().getChildAt(2).setBackgroundResource(R.drawable.camera);
tabHost.getTabWidget().getChildAt(3).setBackgroundResource(R.drawable.profile);
tabHost.getTabWidget().getChildAt(4).setBackgroundResource(R.drawable.Messege);
他の 4 つのイメージを作成し、上位 20% を透明として作成し、中央のカメラをカーブ ベースとして作成します。あなたはこのようにあなたの目標を達成します。
このように灰色の部分が透明部分です。
私はこのようなことをしています:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="0dp"
android:tabStripEnabled="false"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/btn1" />
<ImageView
android:id="@+id/btn1"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btn2"
android:src="@drawable/ic_launcher"/>
<ImageView
android:id="@+id/btn2"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btn3"
android:src="@drawable/ic_launcher"/>
<ImageView
android:id="@+id/btn3"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/ic_launcher"/>
<ImageView
android:id="@+id/btn4"
android:layout_toRightOf="@+id/btn3"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>
<ImageView
android:id="@+id/btn5"
android:layout_toRightOf="@+id/btn4"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>
</RelativeLayout>
</TabHost>
私はTabWidgetのビルドを取り除き、LinearLayoutで自分自身をセットアップしています。後で、メインのタブ アクティビティで onClick 関数を設定するだけです。
お気に入り:
public void onClick(View v)
{
switch(v.getId())
{
case R.id.btn1:
tabHost.setCurrentTab(0);
break;
case R.id.btn2:
tabHost.setCurrentTab(1);
break;
case R.id.btn3:
tabHost.setCurrentTab(2);
break;
case R.id.btn4:
tabHost.setCurrentTab(3);
break;
case R.id.btn5:
tabHost.setCurrentTab(4);
break;
}
}