2011-08-04 5 views
0

실제로 내 탭의 오른쪽 하단에 커브를 표시하고 싶습니다. 어떻게 할 수 있습니까? 코드 ... 내가 사용한 코드 ..안드로이드에서 곡선 또는 둥근 탭을 만드는 방법

코드

<?xml version="1.0" encoding="UTF-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- When selected, use grey --> 

<item android:drawable="@drawable/ic_tab_artists_white" 
     android:state_selected="true" 
     android:state_pressed="false" /> 
<!-- When not selected, use white--> 
<item android:drawable="@drawable/ic_tab_artists_grey" /> 
</selector> 

코드 된 .java 파일

   Resources res = getResources(); 
       final TabHost MainTabHost = getTabHost(); 
       TabHost.TabSpec spec; 
       Intent intent; 

       MainTabHost.getTabWidget().setStripEnabled(false); 

       //call calendar Activity class 
       intent = new Intent().setClass(this, CalendarForm.class); 
       intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
       spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost1)).setIndicator("Calendar", 
       res.getDrawable(R.drawable.calendar_ic)).setContent(intent); 

       MainTabHost.addTab(spec); 

       //call History Activity class 
       intent = new Intent().setClass(this, HistoryForm.class); 
       intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
       spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost2)).setIndicator("History", 
       res.getDrawable(R.drawable.calendar_ic)).setContent(intent); 
       MainTabHost.addTab(spec); 

       //call Statistic Activity class 
       intent = new Intent().setClass(this, StatisticForm.class); 
       intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
       spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost3)).setIndicator("Statistic", 
       res.getDrawable(R.drawable.calendar_ic)).setContent(intent); 
       MainTabHost.addTab(spec); 

       //setbackground Style of tabHost          
       MainTabHost.setCurrentTab(0); 
       MainTabHost.getTabWidget().setWeightSum(3); 
       final TabWidget tabHost=getTabWidget(); 
       MainTabHost.setBackgroundResource(R.drawable.back_image); 

       for (int j = 0; j < MainTabHost.getTabWidget().getChildCount(); j++) 
       { 
        ((TextView)tabHost.getChildAt(j).findViewById(android.R.id.title)).setTextColor(Color.parseColor("#FFFFFF")); 
        ((TextView)tabHost.getChildAt(j).findViewById(android.R.id.title)).setTextSize(16); 
       } 
에 대한 두 번째 XML에 대한 XML을

<?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="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TabWidget 
    android:id="@android:id/tabs" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"/> 
    <FrameLayout 
    android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"/> 
    </LinearLayout> 
</TabHost>  

코드3210

enter image description here

이 내가 탭이 지금은 u는 아이디어를 얻을 수 아래의 우측 하단

+0

당신이 가지고있는 것의 스크린 샷을 보여주고 달성하고자하는 것을 캡쳐 화면으로 보여줄 수 있습니까? – glenatron

+0

나는 당신에게 스냅 샷 u를 보냈습니다. – AndroidDev

답변

2

에서 내 탭의 곡선이 질문을 확인 할 정사각형 got..here 것입니다.

how-to-put-some-finishing-touches-rounded-edges.

또 다른 해결책은 탭 위에 둥근 모서리가있는 이미지를 설정하는 것입니다. 알다시피, 안락한 솔루션이지만 작동합니다.

tab = tabs.newTabSpec("tab_Busquedas"); 
tab.setContent(new Intent().setClassName("com.grapp", "com.grapp.homes").putExtras(bundle)); 
tab.setIndicator(null,null); 
tabs.addTab(tab); 
//here you set the image with rounded corners over the tab. 
tabs.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.mytab_roundedcorners); 

R.drawable.mytab_roundedcorners은 셀렉터가됩니다.

편집 :

는 드로어 블 폴더에 XML 파일의 코드를

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
<corners android:bottomLeftRadius="0dp" 
    android:bottomRightRadius="0dp" 
    android:topLeftRadius="5dp" 
    android:topRightRadius="5dp" /> 
</shape> 

를 넣습니다. 그런 다음 xml 파일을 탭의 배경으로 사용하십시오. 그것은 둥근 모서리가 될 것입니다.

+0

괜찮습니다.하지만 다른 옵션은 없습니다. 나는 그쪽의 탭에 배경 이미지를 넣고 싶지 않습니다. – AndroidDev

+0

@Anshuman : 주어진 링크를지나 갔습니까? 이미지를 붙여 넣지 않고 둥근 모서리를 만듭니다. – Hussain

+0

예치 나는 그 링크를 통해 갔지만 나는 내 코드에 링크가 주어진 xml 코드를 넣을 수 없다. 그걸 도와주게. – AndroidDev

관련 문제