2011-12-09 9 views
0

私はこのようなカスタムタブレイアウトを作成しました。私はトップバーのバックグラウンドを2つの部分で陰影を付けたようにしたいのですが、 :androidの陰影の背景を持つカスタムタブバー

これは私のmain.xml

<?xml version="1.0" encoding="utf-8"?> 


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="fill_parent" 
android:layout_height="fill_parent" android:background="@drawable/bac_tab" 
android:id="@+id/mymain_layout" android:weightSum="1"> 

<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" android:background="@drawable/bac_tab"> 
    <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" 
      android:background="#000" /> 
     <TabWidget android:id="@android:id/tabs" android:layout_marginTop="5dip" android:layout_marginBottom ="5dip" 
      android:layout_width="fill_parent" 
      android:layout_marginLeft="30dip" android:layout_marginRight="30dip" android:background="@null" 
      android:layout_height="40dp" /> 

     <FrameLayout android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" android:layout_height="fill_parent"> 
      <LinearLayout android:background="#ffffff" 
       android:orientation="vertical" android:layout_width="fill_parent" 
       android:layout_height="fill_parent" android:id="@+id/main"> 
       <ListView android:id="@+id/list" android:layout_width="fill_parent" 
        android:background="#ffffff" android:layout_height="fill_parent" 
        android:layout_weight="1" /> 
       <TextView android:id="@+id/empty" android:layout_width="wrap_content" 
        android:layout_height="wrap_content" android:gravity="center" 
        android:text="" android:textColor="#000000" /> 
      </LinearLayout> 
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/mainlayout" android:orientation="vertical" 
       android:layout_width="fill_parent" android:layout_height="fill_parent"> 
       <TextView android:id="@+id/empty" android:layout_width="wrap_content" 
        android:layout_height="wrap_content" android:gravity="center" 
        android:text="" android:textColor="#000000" /> 

      </RelativeLayout> 
     </FrameLayout> 
    </LinearLayout> 
</TabHost> 
<RelativeLayout android:gravity="bottom" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" android:background="@drawable/bac_tab"> 

</RelativeLayout> 

とbac_tab.xml

<?xml version="1.0" encoding="utf-8"?> 
<selector 
xmlns:android="http://schemas.android.com/apk/res/android"> 


<item>   
    <shape> 
     <gradient 
      android:endColor="#000000" 
      android:startColor="#696969" 
      android:centerColor="#696969" 
      android:angle="270" /> 
     <stroke 

      android:color="#696969" /> 
     <padding 
      android:left="2dp" 
      android:top="3dp" 
      android:right="2dp" 
      android:bottom="3dp" /> 
    </shape> 
</item> 
です10

答えて

1

を使用してみてください:

<?xml version="1.0" encoding="utf-8"?> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="fill_parent" 
android:layout_height="fill_parent" android:background="@drawable/bac_tab" 
android:id="@+id/mymain_layout" android:weightSum="1"> 

*<!---by adding this in the background-----> 

    <RelativeLayout android:gravity="bottom" 
      android:layout_width="fill_parent" android:layout_height="51dp" 
      android:layout_alignParentTop="true" android:layout_alignParentLeft="true" 
      android:background="@drawable/newbac"></RelativeLayout> 

    <!---------------------------------------------------------->* 

    <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" ***android:background="@drawable/@android:color/transparent">*** 
     <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" 
       android:background="#000" /> 
      <TabWidget android:id="@android:id/tabs" android:layout_marginTop="5dip" android:layout_marginBottom ="5dip" 
       android:layout_width="fill_parent" 
       android:layout_marginLeft="30dip" android:layout_marginRight="30dip" android:background="@null" 
       android:layout_height="40dp" /> 

      <FrameLayout android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" android:layout_height="fill_parent"> 
       <LinearLayout android:background="#ffffff" 
        android:orientation="vertical" android:layout_width="fill_parent" 
        android:layout_height="fill_parent" android:id="@+id/main"> 
        <ListView android:id="@+id/list" android:layout_width="fill_parent" 
         android:background="#ffffff" android:layout_height="fill_parent" 
         android:layout_weight="1" /> 
        <TextView android:id="@+id/empty" android:layout_width="wrap_content" 
         android:layout_height="wrap_content" android:gravity="center" 
         android:text="" android:textColor="#000000" /> 
       </LinearLayout> 
       <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/mainlayout" android:orientation="vertical" 
        android:layout_width="fill_parent" android:layout_height="fill_parent"> 
        <TextView android:id="@+id/empty" android:layout_width="wrap_content" 
         android:layout_height="wrap_content" android:gravity="center" 
         android:text="" android:textColor="#000000" /> 

       </RelativeLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 
    <RelativeLayout android:gravity="bottom" 
     android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" android:background="@drawable/bac_tab"> 

    </RelativeLayout> 
0

私はTabHostのための透明な背景を使用することにより、望ましい結果を持って、1層目の影の背景に使用レイヤーリストに

<?xml version="1.0" encoding="utf-8"?> 
<layer-list 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    > 
    <item> 
     <shape 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="rectangle" 
      > 

      <gradient 
       android:endColor="#000000" 
      android:startColor="#696969" 
      android:angle="270" 
      android:centerColor="#696969" 


       android:type="linear" 
       />  
     </shape> 
    </item> 

</layer-list> 
+0

が動作していませんが..: ( –

関連する問題