
<androID.support.v7.Widget.Toolbar xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:background="@color/primarycolor" androID:fitsSystemwindows="true" androID:theme="@style/Toolbartheme"></androID.support.v7.Widget.Toolbar>
并将其包含在activity_main.xml中,如下所示:
<androID.support.v4.Widget.DrawerLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.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" />........
在styles.xml中我使用以下属性,
<item name="androID:windowTranslucentStatus">true</item>
有了这一切一切正常,我得到以下结果,
单击编辑文本视图(00.00)时会出现此问题.单击编辑文本视图或页面中任何编辑文本视图的时刻,工具栏只会展开.见下图:
现在,我能够通过在activity_main.xml中放置androID:fitsSystemwindows =“true”来纠正这个问题,如下所示:
<androID.support.v4.Widget.DrawerLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.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://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.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/colorPrimary" 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,您的colorPrimaryDark属性中的永久灰色颜色将不会更改,将始终为灰色且仅为灰色.
2)定义你的活动xml:
<androID.support.v4.Widget.DrawerLayout 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: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视图时展开所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)