K1-*_*ria 6 android android-actionbar
我正在使用Android Studio进行编程.目标SDK为23,最低SDK为15
我正在尝试删除操作栏和滑动标签布局之间的阴影.但我无法做到.
注意:阴影仅在Android 5和更高版本中可见.
我已经使用<item name="elevation">0dp</item>和getSupportActionBar().setElevation(0);
,但它仍然不工作...
我的Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="elevation">0dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的风格V21
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的MainActivity.java onCreateCode:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setElevation(0);
Run Code Online (Sandbox Code Playgroud)
....
Cor*_*ton 10
你错过了你风格的前缀.
<item name="android:elevation">0dp</item>
Run Code Online (Sandbox Code Playgroud)
那说你也可以直接在你的上面设置它 AppBarLayout
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:elevation="0dp"
android:theme="@style/AppTheme.AppBarOverlay">
Run Code Online (Sandbox Code Playgroud)
或者我喜欢做的是移动SlidingTabLayout进去,AppBarLayout以便阴影出现在它下面:
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay"
/>
<com.ccswe.SmokingLog.views.widgets.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="wrap_content"
android:layout_height="@dimen/tab_layout_height"
/>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4436 次 |
| 最近记录: |