Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android上布局的标题栏样式_Android_Android Linearlayout - Fatal编程技术网

android上布局的标题栏样式

android上布局的标题栏样式,android,android-linearlayout,Android,Android Linearlayout,我想使用线性布局创建这样的自定义标题栏。我不知道如何在底部获得3D/shodow效果。有什么建议吗 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape android:shape="rectangle">

我想使用线性布局创建这样的自定义标题栏。我不知道如何在底部获得3D/shodow效果。有什么建议吗

<?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="@android:color/darker_gray" />
            <corners android:radius="0dp"/>
        </shape>
    </item>
    <item android:bottom="1dp" android:top="1dp">
        <shape
            android:shape="rectangle">
            <solid android:color="#019BD9"/>
            <corners android:radius="0dp"/>
        </shape>
    </item>
</layer-list>


您可以集成appcompact

<android.support.v7.widget.Toolbar
    android:id=”@+id/my_awesome_toolbar”
    android:layout_height=”wrap_content”
    android:layout_width=”match_parent”
    android:minHeight=”?attr/actionBarSize”
    android:background=”?attr/colorPrimary” />

要使用工具栏,只需将其添加到布局中即可

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/color_alizarin"
        android:titleTextAppearance="@color/White"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
注意:setSupportActionbar()仅在扩展ActionBarActivity或AppCompactActivity时可用。相反,这是唯一的活动

[备选方案]

如果你不想使用工具栏。 只需将下面的视图添加到需要阴影的位置

<View
      android:layout_width="match_parent"
      android:layout_height="5dp"
      android:background="@drawable/toolbar_dropshadow" />

这里是工具栏\u dropshadow可绘制

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
    android:startColor="@android:color/transparent"
    android:endColor="#88333333"
    android:angle="90"/>
</shape>


你必须使用工具栏。你听说过Android在API 21之后发布的新工具栏概念吗。那会给你这个阴影。如果您需要更多帮助,请告诉我。这是工具栏/操作栏,不要重新发明轮子,对于阴影,请在API 21及以上版本上使用setElevation,对于API 21以下版本,请使用FrameLayout的
android:foreground
标记。您可以从github上的iosched应用程序中获取shadow.png图像,它位于xxhdpi文件夹中。感谢您的回复。标题栏对我没有帮助。我计划在不同的地方使用相同的栏作为标题样式,而不仅仅是顶部的标题栏。所以需要一个线性布局的风格解决方案。阴影呢?谢谢你的回答。标题栏对我没有帮助。我计划在不同的地方使用相同的栏作为标题样式,而不仅仅是顶部的标题栏。所以需要一个线性布局的风格解决方案……你们都确定吗?因为我认为这不是最好的做法。在屏幕中间或其他地方显示标题栏之类的组件可能会让用户感到困惑。请与设计师或你的客户核实他们为什么真的需要这个-我发现了这个-也许它会帮助你我使用它作为标题,不会有任何导航或其他任何东西。这是标题中内容的对比。对不起,我把你弄糊涂了。我的问题是如何显示深度。请参阅我的替代解决方案。我希望有帮助。谢谢,我的问题是如何显示深度。不是怎么给酒吧遮阴。我认为上图中的工具栏是纯色的OK,我的第二个替代解决方案不是工具栏。你可以把视图放在线性布局的底部,在你想显示深度的地方。我没听懂。你介意改进或更改我上面的代码吗。我将把它应用到线性布局中。Thank位于上面的原始帖子中。唯一的问题是我将该xml分配给一个线性布局的android:background=“@drawable/background\u with\u shadow”,该布局只有一个文本视图来显示文本。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
    android:startColor="@android:color/transparent"
    android:endColor="#88333333"
    android:angle="90"/>
</shape>