avi*_*i12 1 user-interface android kotlin navigation-drawer
我最近在Android Studio中打开了一个项目,并选择了一个导航抽屉活动.它创建了导航抽屉,除了它以我不喜欢的方式显示 - 导航抽屉显示在标题栏的顶部,例如:
相反,我希望它像:
在这个"正确"的示例中,标题栏 - "主页"与关闭箭头一起显示,同时导航抽屉打开.
文件来源:
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.avi12.soundcloudinstantdownloader.MainActivity"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.avi12.soundcloudinstantdownloader.MainActivity"
tools:showIn="@layout/app_bar_main">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="What this app can download:"/>
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView"
android:layout_below="@+id/textView"
android:layout_marginLeft="17dp"
android:layout_marginStart="17dp"
android:text="Single tracks"/>
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView8"
android:layout_alignStart="@+id/textView8"
android:layout_below="@+id/textView8"
android:text="Playlists, a.k.a albums"/>
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView9"
android:layout_alignStart="@+id/textView9"
android:layout_below="@+id/textView9"
android:text="User likes (though only some, due to SoundCloud limiting their API)"/>
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView"
android:layout_below="@+id/textView10"
android:layout_marginTop="12dp"
android:text="Instantly download songs by sharing it from SoundCloud with this app!"/>
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView11"
android:layout_alignStart="@+id/textView11"
android:layout_below="@+id/textView11"
android:layout_marginTop="18dp"
android:text="Alternatively, you can search the song, and even paste its URL:"/>
<EditText
android:id="@+id/inputDownload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView12"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="@+id/textView12"
android:layout_below="@+id/textView12"
android:ems="10"
android:hint="Search query or URL"
android:inputType="textUri"
android:singleLine="true"/>
<TextView
android:id="@+id/error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
编辑
在Tomer Shemesh的建议之后,<android.support.v7.widget.Toolbar
改为:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:layout_marginTop="?attr/actionBarSize"/>
Run Code Online (Sandbox Code Playgroud)
然后,结果是:
所以目前还没有解决方案.
小智 5
添加到Tomer建议,android:layout_marginTop="?attr/actionBarSize"
应该适用于android.support.design.widget.NavigationView
.我没看到导航视图app_bar_main.xml
.
添加此选项将为您提供带有不透明叠加层的操作栏.它看起来像这个 带有不透明覆盖图的图像
您可以通过设置去除不透明的覆盖scrimColor
,以透明的DrawerLayout
你Navigation Drawer Activity
.
mDrawerLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_refonte_base, null);
mDrawerLayout.setScrimColor(ContextCompat.getColor(this,android.R.color.transparent));
现在它看起来像这样. 图像与稀松布颜色透明
归档时间: |
|
查看次数: |
256 次 |
最近记录: |