java - 工具栏上移

标签 java android

工具栏上移

http://i.stack.imgur.com/QCXYs.png

如何制作法线?

如何制作透明工具栏?我使用 mike penz 的抽屉和标签 activity_main.xml

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


<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_activity_DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:background="?attr/colorPrimary" />

    <su.gamepoint.opendomofon.pro.sliding.SlidingTabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="2dp"
        android:background="@color/ColorPrimary" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1">
    </android.support.v4.view.ViewPager>

</LinearLayout>
</android.support.v4.widget.DrawerLayout>

最佳答案

有两种方法。

首先通过xml:您可以为不同的API级别设置不同的尺寸,并在您的AppBar中设置padding。

其次通过 java:创建如下所示的方法

 public int getStatusBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}

然后在您的 onCreate() 中:

   set this padding on your Appbar.

关于java - 工具栏上移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39237693/

相关文章:

java - postgresql jdbc 中的结果集关闭问题

android - 用于在 android 中浏览 XML(特别是 rss)的 Intent 过滤器

java - 如何动态加载 R.styleable 资源?

java - 更新上传过程的进度对话框

java - 如何将数据从 MySQL 查询传递到结果集?

java - 通过Jackson注解将带有大量属性的json反序列化为java类

java - 在 Web 服务和客户端之间共享 Java 类

java - 以编程方式更改 Android 5 (L) 上的 WiFi 配置

java - Base 64 解码 byte[] 转换为字符串

android - 将连续语音识别添加到我的 Android 应用程序