天道酬勤,学无止境

android-drawer

Android 带抽屉的 Google 搜索栏(Android Google Search Bar with Drawer)

问题 我的应用程序目前是使用单活动方法实现的(使用具有一个主要活动和多个片段的导航架构组件)。 我目前正在使用带抽屉的工具栏。 我的应用目前看起来像这样: 然而,在现代谷歌应用程序(谷歌照片、gmail 等)中,谷歌已经实现了一种新的导航方式,使用搜索字段并在其中实现抽屉,如下所示: 我想用搜索栏和抽屉菜单替换这个工具栏,就像谷歌应用程序一样。 有人可以帮助我提供一些关于如何实现这一目标的代码吗? 我的主要活动如下: <?xml version="1.0" encoding="utf-8"?> <layout 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"> <androidx.drawerlayout.widget.DrawerLayout android:id="@+id/Drawer_Main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.main.main

2022-01-16 11:57:46    分类:技术分享    android   kotlin   android-architecture-navigation   android-search   android-drawer

右抽屉 - 如何添加工具栏按钮?(Right Drawer - how to add Toolbar button?)

问题 我通过在 GitHub 的一个简单测试项目中添加工具栏和右侧抽屉来扩展著名的 Google Navigation Drawer 示例: 如何在工具栏上添加一个“汉堡”按钮 - 这将打开右抽屉(目前你只能用手指滑动它)? 左侧抽屉的“汉堡”按钮已经存在并且运行良好(可能是由 ActionBarDrawerToggle 添加的?) 这是我当前的activity_main.xml: <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"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk

2022-01-14 09:26:20    分类:技术分享    android   android-layout   material-design   android-toolbar   android-drawer

Right Drawer - how to add Toolbar button?

I have extended the well-known Google Navigation Drawer Example by adding Toolbar and right-side Drawer in a simple test project at GitHub: How to add a "burger" button to the Toolbar - which would open the right Drawer (currently you can only swipe it with a finger)? The "burger" button for the left Drawer is already there and works well (probably added by ActionBarDrawerToggle?) Here is my current activity_main.xml: <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

2022-01-14 04:28:16    分类:问答    android   android-layout   material-design   android-toolbar   android-drawer

Android Google Search Bar with Drawer

My app is currently implemented with the Single activity approach (Using navigation architecture component with one main activity and several fragments). I am currently using a toolbar with a drawer. My app currently look like this: However in the modern google apps (Google photos, gmail etc..), Google has implemented a new way of navigating using a search field with an implemented drawer in it as shown below: I want to replace this toolbar with a search bar and the drawer menu exactly like the Google apps. Can someone help me with some code on how to achieve this? My main activity is as

2022-01-10 18:19:33    分类:问答    android   kotlin   android-architecture-navigation   android-search   android-drawer

DrawerLayout 必须使用 MeasureSpec.EXACTLY 进行测量。 在 android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:994)(DrawerLayout must be measured with MeasureSpec.EXACTLY. at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:994))

问题 这是我的mainlayout文件。 这是我编写与导航抽屉相关的代码的主要布局文件,还通过使用 include 包含工具栏。 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"> <android.support.v4.widget.DrawerLayout android:id="@+id/navigation_Drawerlayout" android:layout_width="wrap_content" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/navigation_drawerlayout" /> <android.support.design.widget

2021-10-21 01:43:44    分类:技术分享    android   android-linearlayout   android-drawer

如何在 DrawerLayout 和 NavigationView 中使用自定义字体(How to use custom fonts in DrawerLayout and NavigationView)

问题 我想使用 Android 的DrawerLayout和NavigationView作为菜单,但我不知道如何让菜单项使用自定义字体。 有没有人有成功的实施? 回答1 使用此方法传递抽屉中的基本视图 public static void overrideFonts(final Context context, final View v) { Typeface typeface=Typeface.createFromAsset(context.getAssets(), context.getResources().getString(R.string.fontName)); try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } } else if (v instanceof TextView) { ((TextView) v).setTypeface(typeface); } } catch (Exception e) { } } 回答2 奥马尔·马哈茂德的回答会奏效。

2021-09-29 15:49:25    分类:技术分享    android   android-menu   android-fonts   android-typeface   android-drawer

DrawerLayout must be measured with MeasureSpec.EXACTLY. at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:994)

Here is the my mainlayout file . This is the main layout file where I write the code related to navigation drawer,also include the toolbar by using include. <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"> <android.support.v4.widget.DrawerLayout android:id="@+id/navigation_Drawerlayout" android:layout_width="wrap_content" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start">

2021-06-28 08:27:37    分类:问答    android   android-linearlayout   android-drawer

How to use custom fonts in DrawerLayout and NavigationView

I want to use Android's DrawerLayout and NavigationView for menus, but I don't know how to have the menu items use a custom font. Does anyone have a successful implementation?

2021-06-09 13:15:00    分类:问答    android   android-menu   android-fonts   android-typeface   android-drawer

CoordinatorLayout + AppBarLayout + NavigationDrawer(CoordinatorLayout + AppBarLayout + NavigationDrawer)

问题 合并时,我有一个布点问题CoordinatorLayout与AppBarLayout和NavigationDrawer 。 问题在于,NavigationDrawer及其内容隐藏在工具栏的后面。 我已经做了很多研究,并尝试了许多重组,但是没有一个“解决方案”可以解决我的问题。 可以在这个小的Webm视频中找到一个演示:https://www.dropbox.com/s/i5zfc2x2ts2fws7/navigation_drawer_stackoverflow32523188.webm?dl=0 基本样式是Theme.AppCompat.Light.NoActionBar 。 我的activity_overview.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" android:id="@+id/overview_coordinator_layout" android:layout_width="match

2021-05-08 14:06:21    分类:技术分享    android   android-layout   android-coordinatorlayout   android-appbarlayout   android-drawer

如何在Android的ExpandableListView中添加三级ListView(How to add Three Level ListView in ExpandableListView in android)

问题 我想在ExpandableListView中再添加一个级别。在当前的ExpandableListView中有两个级别,我如何再添加一个级别。 我是android开发的新手,请帮助我。 提前致谢! 我的MainActivity.java:- private Toolbar mToolbar; ExpandableListAdapter listAdapter; ExpandableListView expListView; List<String> listDataHeader; HashMap<String, List<String>> listDataChild; // private FragmentDrawer drawerFragment; ArrayList<String> arraylist1,arraylist2,arraylist3,arrayList4,arrayList5; int cnt = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mToolbar = (Toolbar) findViewById(R.id

2021-04-12 11:09:45    分类:技术分享    java   android   android-layout   android-listview   android-drawer