相关疑难解决方法(0)

如何设置导航抽屉从右到左打开

首先我知道这个问题出现在此之前,但在尝试了很多之后我仍然没有成功.我从Android Developers网站开始研究这个例子 .

我正在尝试将菜单设置为从右到左打开,而不是在示例中如何实现(从左到右).此外,我想将打开菜单按钮移动到操作栏的右侧.我也在这里提出了一些答案,例如在这个答案中.

我尝试改变视图和布局的重力,但我得到错误:

没有抽屉视图发现绝对重力LEFT

你可以帮我弄清楚我的代码中有什么问题,为了设置菜单从右边打开,我应该改变什么,并将操作栏按钮移动到右侧?

xml代码在这里:

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

    <FrameLayout
        android:id="@+id/content_frame"
        android:layoutDirection="rtl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

    <ListView android:id="@+id/left_drawer"
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="10dp"
        android:background="#111"/>

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

android right-to-left navigation-drawer

73
推荐指数
4
解决办法
11万
查看次数

如何更改导航抽屉字体?

我想在android中使用我自己的字体导航抽屉.我根据这个答案使用了android studio附带的库:https://stackoverflow.com/a/23632492/4393226.但我不知道如何更改字体并使其成为RTL.我搜索了很多,我发现了如何制作抽屉RTL.我用这个代码:

getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
Run Code Online (Sandbox Code Playgroud)

Android - 右侧的导航抽屉可能吗?

但正如您所知,这仅适用于API 17及更高版本.请帮忙!如何更改菜单字体?如何以正确的方式进行布局RTL?!

编辑:我的字体"TTF"文件是资产/字体,我知道如何使用java设置文本视图,但我不知道如何将其设置为导航抽屉菜单.

fonts android right-to-left navigation-drawer

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

从DrawerLayout格式从右到左滑动ExpandableListView

如何从DrawerLayout格式从右到左滑动ExpandableListView

我想在屏幕的右下角显示ExpandableListView,我该怎么做?

<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">

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ExpandableListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/white"
        android:dividerHeight="0dp"
      />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

带有ListView和自定义标头的NavigationDrawer片段

我遇到了问题,我无法解决.在我的应用程序中,我有一个导航抽屉定义如下:

activity_main.xml中

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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/container"
    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.
     If you're not building against API 17 or higher, use
     android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-listview android-fragments android-navigation

7
推荐指数
1
解决办法
1993
查看次数

如何实现从右侧打开抽屉菜单

我按照本教程创建了一个导航抽屉

但我需要的是,我需要从右侧打开相同的抽屉菜单。有谁知道如何实现这一目标?

以下是我的 xml

<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/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<LinearLayout
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    >
    <include
        android:id="@+id/toolbar"
        layout="@layout/tool_bar"
    />
    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </FrameLayout>

</LinearLayout>
<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="right"
    app:headerLayout="@layout/header"
    app:menu="@menu/drawer"
    />
Run Code Online (Sandbox Code Playgroud)

并在代码中

  // Initializing Drawer Layout and ActionBarToggle
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.openDrawer, R.string.closeDrawer){

        @Override
        public void onDrawerClosed(View drawerView) {
            // Code here will be triggered once the drawer closes as we dont want anything to happen so we …
Run Code Online (Sandbox Code Playgroud)

android navigation-drawer drawerlayout

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