English 中文(简体)
如何创建中心升起制表栏?
原标题:How to create center raised tabbar?

我要创建 TabBar 如下面的图像 :

""https://i.sstatic.net/iaEXP.jpg" alt="此处的内置图像描述"/"

这里所有的制表栏都是正常的。 只是它们都是自定义的。 现在我要像在图像上方一样创建制表栏。 在其中将制表栏升起 。

那么,我应该做些什么来使它成为可能呢?

如果有任何演示的话,这将是很好的。

帮帮我吧

最佳回答

您可以将 Tab 部件中的背景图像设置为

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);

创建像其它四个图像一样的图像, 如前20%的图像, 作为透明的和中间的摄像头, 作为您的曲线基础 。 您将以此实现您的目标 。

Like this where grey part is Transparency part. enter image description here

""https://i.sstatic.net/7jjjm9.jpg" alt="此处输入图像描述"/ >

问题回答

我在做这样的事:

<?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>

I m get rid off build in TabWidget and setting up my own by LinearLayout. Later you just need to set onClick function in main Tab Activity.

类似 :

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;
            }
    }    




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签