大佬教程收集整理的这篇文章主要介绍了android – 工具栏在单击EditText视图时展开,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<android.support.v7.widget.Toolbar xmlns:android="http://scheR_629_11845@as.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:BACkground="@color/pri@R_262_11035@Color" android:fitsSystemWindows="true" android:theme="@style/ToolbarTheme"> </android.support.v7.widget.Toolbar>
并将其包含在activity_main.xml中,如下所示:
<android.support.v4.widget.DrawerLayout xmlns:android="http://scheR_629_11845@as.android.com/apk/res/android" xmlns:app="http://scheR_629_11845@as.android.com/apk/res-auto" android:id="@+id/navigation_drawer" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <include android:id="@+id/toolbar" layout="@layout/toolbar" /> ........
<item name="android:windowTranslucentStatus">true</item>
有了这一切一切正常,我得到以下结果,
单击编辑文本视图(00.00)时会出现此问题.单击编辑文本视图或页面中任何编辑文本视图的时刻,工具栏只会展开.见下图:
现在,我能够通过在activity_main.xml中放置android:fitsSystemWindows =“true”来纠正这个问题,如下所示:
<android.support.v4.widget.DrawerLayout xmlns:android="http://scheR_629_11845@as.android.com/apk/res/android" xmlns:app="http://scheR_629_11845@as.android.com/apk/res-auto" android:id="@+id/navigation_drawer" android:layout_width="match_parent" android:fitsSystemWindows="true" android:layout_height="match_parent"> ........
我的问题是,虽然这个解决方案有效,但我不确定为什么我必须在布局文件中使用两次相同的属性?什么使工具栏扩展?此外,这是解决此问题的正确方法吗?
编辑 – 从toolbar.xml中删除android:fitsSystemWindows =“true”并将其放在抽屉布局中导致主要活动产生正确的结果,但其他活动有一个白色条.见下图.
1)定义toolbar.xml
<android.support.v7.widget.Toolbar xmlns:android="http://scheR_629_11845@as.android.com/apk/res/android" xmlns:app="http://scheR_629_11845@as.android.com/apk/res-auto" android:id="@+id/toolBarDetalleContacto" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="4dp" android:BACkground="?attr/colorPri@R_262_11035@" android:fitsSystemWindows="true" app:layout_collapseMode="pin" app:theme="@style/Theme.GpsFriends.Material"> </android.support.v7.widget.Toolbar>
诀窍是在< android.support.v4.widget.DrawerLayout>中的活动xml中使用此属性.父组件并在此处设置属性android:fitsSystemWindows =“true”(也在您的toolbar.xml中).如果您不使用DrawerLayout,您的colorPri@R_262_11035@Dark属性中的永久灰色颜色将不会更改,将始终为灰色且仅为灰色.
2)定义你的活动xml:
<android.support.v4.widget.DrawerLayout xmlns:android="http://scheR_629_11845@as.android.com/apk/res/android" xmlns:tools="http://scheR_629_11845@as.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:fitsSystemWindows="true" tools:context="com.wherefriend.activities.agregaramigos.AgregarAmigosActivity"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:id="@+id/toolbar_main_gps_friends" layout="@layout/toolbar_gps_friends" ></include> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/bBuscar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentright="true" android:layout_alignParentTop="true" android:onClick="buscarAmigos" android:text="Buscar" /> <EditText android:id="@+id/etfragmentCorreo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/bBuscar" android:ems="10" android:inputType="textEmailAddress" /> </RelativeLayout> <ListView android:id="@+id/listaResultado" android:divider="@drawable/horizontal_linear_layout_divider" android:dividerHeight="0dp" android:layout_width="match_parent" android:layout_height="fill_parent" > </ListView> </LinearLayout> </android.support.v4.widget.DrawerLayout>
如您所见,我将第一个子活动xml UI定义为DrawerLayout,但在下面我使用< LinearLayout>包括我的整个用户界面查看组件.首先是我的工具栏,然后是组件的休止符.
结果就是这样,在真正的Nexus 4 – LG API第22版测试:
以上是大佬教程为你收集整理的android – 工具栏在单击EditText视图时展开全部内容,希望文章能够帮你解决android – 工具栏在单击EditText视图时展开所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。