Android自学之路,主界面的搭建Drawerlayout的使用
16lz
2021-01-26
首先写一个ActivityBase类,里面封装了一些我们常用的方法,比如说打开Activity,Toast等等
protected void OpenActivity(Class<?> pClass) { Intent _intent = new Intent(); _intent.setClass(this, pClass); startActivity(_intent); } class做参数的时候形参是Class<?>mclass 这次我自己规定,形参一律使用_class的形式,成员变量使用mclass的形式。 由于我们要用到ToolBar所以要在Manifest中将style中的Theme改写为NoActionTheme`<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style></resources>````OK其他的暂时不变,<div class="se-preview-section-delimiter"></div>
这里写代码片
“`
这是在drawerlayout中的代码drawerlayout包括两部分
<android.support.v4.widget.DrawerLayout android:layout_height="match_parent" android:layout_width="match_parent" android:layout_below="@+id/toolbar" android:fitsSystemWindows="true"> <include layout="@layout/drawercontent"></include> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorBlue" android:layout_gravity="start|left" android:layout_marginEnd="20dip" android:layout_marginRight="20dip" android:orientation="vertical" android:paddingTop="48dp" ></LinearLayout> </android.support.v4.widget.DrawerLayout>
要注意一个问题,drawerlayout的定义中,长与宽不能写wrap_parent
这是在drawerlayout中的代码drawerlayout包括两部分,
更多相关文章
- Android中ViewPager and HorizontalScrollVIew 冲突
- 【Android(安卓)Studio】AS 使用记录06「常用快捷键」
- react-native之module的使用
- Android中visibility属性
- V4包下Fragment替换为源码下Fragment的心路历程
- 基于unity3d游戏的android版本逆向初探
- SurfaceFlinger启动过程分析(一)、(二)、(三)、(四)【转】
- Ubuntu 18.04 环境下编译Android(安卓)源码
- AndroidStudio使用Git发布与更新,同步,关联github