开发者

Set tabView in the Application

I have Set开发者_JS百科 the tabview in My Application But all tab shows very near to eachother. . i want to Set the Little Space between then. . . How it is Possible ? Thanks in Advance.


<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <View android:layout_width="fill_parent" android:layout_height="0.5dip"

Here, I set 0.5 you can st 1 dp and you can set a tabdiver.9.png file.

            android:background="#000" />
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent" android:layout_height="55dip"
            android:layout_marginLeft="0dip" android:layout_marginRight="0dip" />
        <View android:layout_width="fill_parent" android:layout_height="5dip"
            android:background="#696969" />
        <View android:layout_width="fill_parent" android:layout_height="1dip" 
            android:background="#000" />
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent" android:layout_height="fill_parent" />
    </LinearLayout>
</TabHost>

Try this.


You could use setIndicator(View) to build tab from own view, and in your custom view (inflated for example from the XML) set the proper margins / paddings. Refere to my post for more info.


You can add space in the tabview item by giving a margin inside that. Use the code below.

for(int i=0; i < mTabLayout.getTabCount(); i++) {  
     View tab = ((ViewGroup) mTabLayout.getChildAt(0)).getChildAt(i); 
     ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) 
     tab.getLayoutParams(); > p.setMargins(0, 0, 50, 0); > tab.requestLayout();
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜