drawerlayout

ActionBarDrawerToggle with AppCompatActivity and Toolbar Back button with Fragments

风格不统一 提交于 2019-12-02 12:01:47
问题 I am using the ActionBarDrawerToggle with NavigationView. My content is displayed using fragments. I am following this stackoverflow question to get the back button press to work but control never flows to onOptionsItemSelected . This is my MainActivity.class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer

Disable DrawerLayout's scrim touch gesture

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 10:31:34
问题 I need to disable touch gesture on the scrim (the red highlighted part). I want to dismiss the drawer only with the swipe. The issue is that when the drawer layout is open and I need to select an element from the ListView below the red highlighted part, what's happend is that the drawer get closed and only at this point I can select an element from the ListView. I need to select the element from the ListView directly, also when the Drawer is opened 回答1: You have to create custom drawer for

开源中国 OsChina Android 客户端源码分析(2)滑动菜单DrawerLayout

一曲冷凌霜 提交于 2019-12-02 08:06:47
1 滑动菜单oschina使用了android.support.v4.widget.DrawerLayout,之前没有用过这个控件,百度了下,大致了解如下: 1.1 类似与LinearLayout,就是一个布局控件。 1.2 使用时,其有两部分组成,主内容VIEW和菜单内容VIEW,并且主内容必须放在菜单内容的前面,才能让DrawerLayout识别谁是菜单的部分,其宽高都需要设置成match_parent。此处的主内容部分是什么?其实就是主界面上的用以显示各个fragment和底部的导航部分,所以oschina就在主界面的布局文件中直接使用了该控件作为最外围的控件。 1.3 DrawerLayout 使用必须在API11之上,所有应用的API的minSdkVersion为11。 布局文件fragment_navigation_drawer.xml ,布局整体两大部分: 可以拖拽的net.oschina.app.widget.CustomerScrollView,内部包含具体菜单项的fragment_navigation_drawer_items.xml布局文件和位于菜单底部的用以设置及关闭功能的fragment_navigation_drawer_foot.xml布局文件。 从对布局文件的分析来看,一下几点值得我们学以致用: 1<net.oschina.app.widget

Android抽屉页面效果

笑着哭i 提交于 2019-12-02 08:06:32
DrawerLayout抽屉布局,现在主流App是越来越多使用DrawerLayout,因为这样出来的效果是比较炫酷的吧!其实抽屉界面很简单,没有网上说的那么复杂,今天我就给大家介绍一种比较简单的抽屉布局,DrawerLayout, 效果图: 1:主布局文件(分为2块,第一块是主页面内容,第二块是抽屉页面内容,这是固定的,必须是这样的格式) < LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" android :layout_width= "match_parent" android :layout_height= "match_parent" android :orientation= "vertical" android :paddingBottom= "@dimen/activity_vertical_margin" android :paddingLeft= "@dimen/activity_horizontal_margin" android :paddingRight= "@dimen/activity_horizontal_margin" android

Android开发之学习官方文档Navigation Drawer记录

随声附和 提交于 2019-12-02 08:06:20
Creating a Navigation Drawer PreviousNext This lesson teaches you to: Create a Drawer Layout Initialize the Drawer List Handle Navigation Click Events Listen for Open and Close Events Open and Close with the App Icon The navigation drawer is a panel that displays the app’s main navigation options on the left edge of the screen. It is hidden most of the time, but is revealed when the user swipes a finger from the left edge of the screen or, while at the top level of the app, the user touches the app icon in the action bar. 导航抽屉式一个显示应用程序的主要导航选项的面板,它显示在屏幕的左边。在大部分时间内它是隐藏状态的,当用户用一直手指从屏幕的左边缘滑动时

Disable DrawerLayout's scrim touch gesture

烈酒焚心 提交于 2019-12-02 07:48:14
I need to disable touch gesture on the scrim (the red highlighted part). I want to dismiss the drawer only with the swipe. The issue is that when the drawer layout is open and I need to select an element from the ListView below the red highlighted part, what's happend is that the drawer get closed and only at this point I can select an element from the ListView. I need to select the element from the ListView directly, also when the Drawer is opened You have to create custom drawer for that like this public class CustomDrawer extends DrawerLayout { public CustomDrawer(Context context) { super

Xamarin.Android : Gravity parameter in DrawerLayout.LayoutParams

ぃ、小莉子 提交于 2019-12-02 07:21:14
I'm trying to create a DrawerLayout programmatically using Xamarin.Android , but I faced a problem when trying to add the ListView which should be dragable form the left .. Here is my code : DrawerLayout myDrawerLayout = new DrawerLayout(this); myDrawerLayout.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); SetContentView(myDrawerLayout); FrameLayout myFrameLayout = new FrameLayout(this); myFrameLayout.LayoutParameters = new DrawerLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

How to set Navigation Drawer icons to the right side of the Item Texts?

我怕爱的太早我们不能终老 提交于 2019-12-02 06:56:12
My Project Screenshot: My Project My Target Design: My Target I have created a (right to left) navigation drawer. It's working fine but when I'm trying to move the icon from the left side to the right side, it's not working. <android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include

Android DrawerLayout (with NavigationView) behind status bar

左心房为你撑大大i 提交于 2019-12-01 10:29:45
I have an app with a DrawerLayout that contains a NavigationView : activity_layout.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" android:fitsSystemWindows="true"> <android.support.constraint.ConstraintLayout android:id="@+id/activity_list" android:layout_width="match_parent" android:layout_height=

How to close drawer menu when click on item menu?

半腔热情 提交于 2019-12-01 09:42:59
This is click event. view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.setBackgroundResource(R.color.colorTim); FragmentManager fragmentManager = ((AppCompatActivity)context).getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); HienThiSanPhamTheoDanhMucActivity hienThiSanPhamTheoDanhMucActivity = new HienThiSanPhamTheoDanhMucActivity(); Bundle bundle = new Bundle(); bundle.putInt("MALOAI",loaiSanPhams.get(groupPosition).getMALOAISP()); bundle.putBoolean("KIEMTRA",false);