相关疑难解决方法(0)

Android设置导航抽屉列表,打开所有设备屏幕的确切一半的屏幕

我想打开所有不同设备的屏幕一半的抽屉列表.我尝试将layout_margineleft 200dp或100dp的硬编码值写入抽屉列表.但它不适用于所有不同设备的设备.那么如何才能为抽屉列表保留一半的屏幕.我也尝试了各种功能,如setLeft(int)等.但由于我使用的是最低版本8,因此其中一些功能不起作用.所以请帮助我.提前致谢.

    mDrawerLayout = (DrawerLayout) view.findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) view.findViewById(R.id.top_sectionlist);
Run Code Online (Sandbox Code Playgroud)

xml为:

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

<android.support.v4.widget.DrawerLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/setting_background" >

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

 android:layout_width="match_parent"
 android:layout_height="fill_parent"
 android:layout_margin="@dimen/top_news_linear_margin"
 android:background="@color/news_list_divider_color"
 android:orientation="vertical"
android:padding="@dimen/top_news_linear_padding" >

</RelativeLayout>

<ListView
 android:id="@+id/drawer_list"
 android:layout_width="wrap_content"
 android:layout_height="fill_parent"
 android:layout_gravity="right"
 android:layout_alignParentTop="true"
 android:background="@color/setting_background"
 android:cacheColorHint="@android:color/transparent"
 android:choiceMode="singleChoice"
 android:divider="@color/news_list_divider_color"
 android:dividerHeight="@dimen/news_list_divider_height"
 />

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

android screen margins navigation-drawer

26
推荐指数
3
解决办法
3万
查看次数

全屏导航抽屉

我有一个抽屉式导航栏中像这样.

我想要做的是打开我的抽屉全屏而不是半屏.如何将此抽屉打开为全屏?

这是xml of drawerlayout

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:fitsSystemWindows="true">

<include
    android:id="@+id/toolbar_layout"
    layout="@layout/app_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/toolbar_layout"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <FrameLayout
        android:id="@+id/activityMainContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/colorPrimary"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:itemTextColor="@android:color/white"
        app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android navigation-drawer drawerlayout

8
推荐指数
1
解决办法
1万
查看次数

如何在Android中制作全屏DrawerLayout?

基本上,我需要一个"选项"菜单,可以通过从左到右滑动屏幕(或点击屏幕左上角的选项按钮)来访问.我还需要它来覆盖屏幕,但不能完全替换它(它需要是半透明的,以便前面的菜单在它下面可见).到目前为止我所做的事情(我正在研究别人的代码,仍然没有解除所有这些,对于缺乏信息感到抱歉):

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         The drawer is given a fixed width in dp and extends the full height of
         the container. A solid background is used for …
Run Code Online (Sandbox Code Playgroud)

xml layout android drawerlayout

6
推荐指数
2
解决办法
5362
查看次数