2016-12-09 43 views
0

嗨,我想我的片段中的我的tabhost阴影。我的XML代码是如何在Android中给底部的阴影FragmentTabHost?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:layout_marginTop="60dip" 
> 
<android.support.v4.app.FragmentTabHost 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_weight="0" /> 
</android.support.v4.app.FragmentTabHost> 
<FrameLayout 
    android:id="@+id/realtabcontent" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" /> 
</LinearLayout> 

我试过所有解决方案可用在stackoverflow但它不工作。请帮忙。

+0

你是否尝试过FragmentTabHost背景中的层列表阴影? – Vinodh

+0

没有。这个怎么做 ? – Mhandroid

+0

你尝试过'android:elevation =“”'这个属性吗? – Shailesh

回答

0

Layer-list drawable是通过设置背景给阴影效果的方法之一。

请按照此link创建不同的可绘制视图,并检查此链接中提到的View Box Shadows

+0

我只是想要底部的阴影。 – Mhandroid

+0

链接在哪里? –

+0

@Mobile:是的,你可以设置底部。这里有解释 – Vinodh

0

enter image description here在Android中没有这样的属性,显示出阴影。但可能的方式来做到这一点是:

  1. 在底部添加一个普通的LinearLayout与灰色的颜色,在其中加入您的实际布局,保证金为1或2个DP

  2. 有9修补图像在阴影中,并将其设置为背景,以您的线性布局

试试这个..创建layout_shadow.xml,并把在绘制文件夹

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="rectangle"> 
      <solid android:color="#CABBBBBB"/> 
      <corners android:radius="2dp" /> 
     </shape> 
    </item> 

    <item 
     android:left="0dp" 
     android:right="0dp" 
     android:top="0dp" 
     android:bottom="2dp"> 
     <shape android:shape="rectangle"> 
      <solid android:color="@android:color/white"/> 
      <corners android:radius="2dp" /> 
     </shape> 
    </item> 
</layer-list> 

应用到你的布局像这样

android:background="@drawable/layout_shadow" 

接头主机的最终布局

<android.support.v4.app.FragmentTabHost 
android:id="@android:id/tabhost" 
android:background="@drawable/layout_shadow" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" > 

让我知道,如果当我使用fragmenttabhost它是不可能到不行

+0

没有它的不工作。它给整个页面的框阴影。但我只想要底部阴影到标签 – Mhandroid

+0

它在这里完美工作,如果它不适合2dp只需将android:bottom =“4dp”属性更改为4dp或10dp并检查 –

+0

尝试LinerLayout比 –