2016-11-18 68 views
0
<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".Activity_Compose"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay" 
    app:elevation="0dp"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:layout_gravity="right" 
     android:background="?attr/colorPrimary" 
     android:elevation="2dp" 
     android:gravity="right" 
     tools:targetApi="lollipop"> 

     <ImageView 
      android:id="@+id/imgComposeCancel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="@dimen/min_padding" 
      android:contentDescription="@string/image" 
      app:srcCompat="@drawable/exit" /> 

     <com.example.CustomTextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Compose" 
      android:textColor="@color/white" 
      android:textSize="@dimen/min_textsize" 
      app:font="@string/montserrat_regular" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center|right"> 

      <ImageView 
       android:id="@+id/imgComposeAttach" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="@dimen/min_padding" 
       android:contentDescription="@string/image" 
       app:srcCompat="@drawable/mail_attach" /> 

      <ImageView 
       android:id="@+id/imgComposeSend" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="@dimen/min_padding" 
       android:contentDescription="@string/image" 
       app:srcCompat="@drawable/mail_send" /> 

     </LinearLayout> 

     </android.support.v7.widget.Toolbar> 

    </android.support.design.widget.AppBarLayout> 

     <include 
     android:id="@+id/layout_dash_child" 
     layout="@layout/act_compose_view" /> 


    </android.support.design.widget.CoordinatorLayout> 

包括布局在这里Android的工具栏appbarlayout

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 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:orientation="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_compose"> 




    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center|start" 
     android:orientation="horizontal" 
     android:padding="@dimen/most_min_padding" 

     android:weightSum="2"> 


     <com.example.CustomTextView 
      android:id="@+id/txtComposeTo" 
      style="@style/label_text_secondary_compose_mail" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.85" 
      android:gravity="start" 
      android:text="@string/to" 
      app:font="@string/montserrat_light" /> 

     <com.doodle.android.chips.ChipsView 
      android:id="@+id/chipsView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.25" 
      android:nextFocusDown="@+id/cstmBtnAddStaff" 
      app:cv_max_height="130dp" 
      app:cv_vertical_spacing="2dp" /> 

     <com.example.CustomButton 
      android:id="@+id/cstmBtnAddStaff" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.9" 
      android:background="@color/blue" 
      android:nextFocusDown="@+id/cstmBtnAddStaff" 
      android:text="+" 
      android:textColor="@android:color/white" 
      android:textSize="20sp" 
      app:font="@string/montserrat_regular" /> 


    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="0.1dp" 
     android:background="@color/not_black" /> 


    <com.example.CustomEditText 
     android:id="@+id/txtComposeSubjectContent" 
     style="@style/label_text_secondary_compose_mail" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     android:hint="Subject" 
     android:maxLines="1" 
     android:nextFocusDown="@+id/editor" 
     android:padding="@dimen/most_min_padding" 

     android:singleLine="true" 
     android:textCursorDrawable="@drawable/cursor_color" 
     app:font="@string/montserrat_light" 
     app:met_hideUnderline="true" /> 

</LinearLayout> 

why this type of behaviour happening

我的工具栏跑到后面的状态栏。我需要摆脱这个问题。帮助将被upvoted.i添加学生,并在点击txtComposeSubjectContent编辑文本后,包括工具栏在内的所有布局都进入状态栏。什么在这里开始。我没有在这里添加任何样式。

+0

你为什么要appare标签像工具:targetApi =“棒棒糖”在工具栏 –

+0

为海拔=“2dp” – Sev

+0

尝试删除该标签 –

回答

0

我认为你的问题依靠提供AppBarLayout和工具栏的高度,它采用主从样式的高度,尝试使用WRAP_CONTENT,如果你不介意一个非常大的工具栏。

其他办法可以来覆盖AppBarLayout和/或工具栏的样式和玩标准的填充/利润率。

例如:

<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout"> 
    <item name="tabTextAppearance">@style/MyCustomTextAppearance</item> 
    <item name="padding">8dp</item> 
</style> 

<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab"> 
    <item name="textAllCaps">false</item> 
    <item name="android:textSize">@dimen/tab_text_size</item> 
    <item name="android:textColor">@color/red</item> 
</style> 

正如你可以在这里看到即时改变为AppBar布局的标准填充和一些标签我的AppBar内得到的文本提供定制的大小和颜色。

如果这些都不起作用,请首先获取代码,然后尝试在不同设备上使用,如果问题仍然存在,则会发生这种情况,因为您在工具栏中使用自定义视图,并且onDraw()方法由于不正确的onMeasure()方法,如果你真的想坚持这种方法,你会遇到很多麻烦。我认为你这样做是因为你需要协调员布局行为,如果你不介意解释你想达到什么,我们可以提供不同的方法。

+0

我认为这不是高度问题,它就像滚动问题。布局落后于状态栏。 – Sev