Android 安卓-如何在工具栏上实现这种阴影背景效果';什么是纽扣?

Android 安卓-如何在工具栏上实现这种阴影背景效果';什么是纽扣?,android,background,android-toolbar,android-appbarlayout,appbar,Android,Background,Android Toolbar,Android Appbarlayout,Appbar,这个标题很有描述性 创建一个可绘制的类图(bg_transularecent.xml): 然后在你的活动中设置它,比如 setSupportActionBar(findViewById<Toolbar>(R.id.you_toolbar_id)); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowCustom

这个标题很有描述性

创建一个可绘制的类图(bg_transularecent.xml):

然后在你的活动中设置它,比如

setSupportActionBar(findViewById<Toolbar>(R.id.you_toolbar_id));

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowCustomEnabled(true);

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View action_bar_view = inflater.inflate(R.layout.chat_custom_bar,null);
actionBar.setCustomView(action_bar_view);
setSupportActionBar(findViewById(R.id.you\u toolbar\u id));
ActionBar ActionBar=getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowCustomEnabled(true);
LayoutFlater充气器=(LayoutFlater)getSystemService(Context.LAYOUT\u充气器\u服务);
视图操作\栏\视图=充气机。充气(R.layout.chat\自定义\栏,空);
actionBar.setCustomView(action\u-bar\u-view);
或者您可以简单地在工具栏中添加一些视图,如

    <android.support.v7.widget.Toolbar
            style="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:titleTextColor="@color/white"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:backgroundTint="@android:color/transparent">

       //Your views here with bg_transluecent.xml as background

    </android.support.v7.widget.Toolbar>

//以bg_transluecent.xml为背景显示您在此处的视图
setSupportActionBar(findViewById<Toolbar>(R.id.you_toolbar_id));

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowCustomEnabled(true);

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View action_bar_view = inflater.inflate(R.layout.chat_custom_bar,null);
actionBar.setCustomView(action_bar_view);
    <android.support.v7.widget.Toolbar
            style="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:titleTextColor="@color/white"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:backgroundTint="@android:color/transparent">

       //Your views here with bg_transluecent.xml as background

    </android.support.v7.widget.Toolbar>