【问题标题】:Line coming between toolbar and Tabs工具栏和选项卡之间的线
【发布时间】:2016-08-29 06:06:25
【问题描述】:

如何去除工具栏和tablayout之间的深线,我在google上搜索了有人说,给工具栏和tablayout添加一些高程,我做了但是没有用,从工具栏和tablyout删除高程后,它是也不工作。请帮帮我:

tablayout_xml:

<RelativeLayout
    android:id="@+id/main_layout"
    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.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        app:tabGravity="fill"
        android:elevation="2dp"
        app:tabMode="fixed"

        app:font="Nexa Bold.otf"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/appbarColor"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"

        android:layout_below="@id/tab_layout"/>

</RelativeLayout>

activity_toolbar:

<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/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/container_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <android.support.design.widget.AppBarLayout
                android:id="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@color/appbarColor"
                    android:elevation="2dp"
                    app:layout_scrollFlags="scroll|enterAlways"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="@dimen/_15sdp"
                        android:textStyle="bold"
                        android:textColor="#fff"
                        android:layout_gravity="center"
                        android:id="@+id/toolbar_title" />
                    <LinearLayout
                        android:id="@+id/clearllBtn"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_marginRight="5dp"
                        android:layout_gravity="right"
                        android:visibility="gone"
                        android:background="@drawable/toolbar_ripple"
                        android:gravity="center_vertical|center_horizontal">
                        <TextView

                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textSize="@dimen/appbar_txt_size"
                            android:text="Clear"
                            android:textColor="@color/white"

                            android:gravity="center"
                            android:textStyle="bold"
                            android:id="@+id/clear_btn"/>


                    </LinearLayout>


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

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




            <FrameLayout
                android:layout_below="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:background="@color/faintwhite"
                android:id="@+id/frame_container">

            </FrameLayout>





        </RelativeLayout>


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


    <!-- Navigation Drawer-->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:background="@color/white"
       >

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

</android.support.v4.widget.DrawerLayout>

【问题讨论】:

  • android:elevation="0dp" 设置为Toolbar
  • #app:elevation=""

标签: android android-viewpager android-toolbar android-tabs


【解决方案1】:

我遇到了同样的问题,我使用的是android:elevation="0dp",但它没有用。 xml中的AppBarLayout,设置app:elevation="0dp"而不是android:elevation="0dp"

【讨论】:

  • 接受这个答案
  • @Akshay Bhat,一个补充问题:你知道吗,如何更改标签文本的字体。
  • @AkshayBhat,stackoverflow 说需要再等 2 分钟才能接受答案:P
  • 字体更改请参考以下链接。希望对您有所帮助:stackoverflow.com/questions/31067265/…
【解决方案2】:

我有同样的问题并使用android:elevation="0dp"app:elevation="0dp"但问题没有解决。然后我动态改变了工具栏的高度。通过使用这个

getSupportActionBar().setElevation(0);

它对我有用。

【讨论】:

    【解决方案3】:

    删除您的相对布局并将 TabLayout 放在工具栏下方的 appbarlayout 中,并删除人们建议添加的所有高程。这是正确的做法。如果它不适合你,我很乐意提供帮助。

    【讨论】:

    • 谢谢,这适用于我的情况。我知道您已经有一段时间没有回答这个问题了,但是如果您碰巧阅读并记住了-我想问一下为什么-为什么我们需要将内容放入应用栏布局中。它确实有效,没问题 - 但它有点违反直觉。我能够找到带有标签的示例,但我的案例是全部内容。
    【解决方案4】:

    转到工具栏并仅在工具栏和应用栏布局中设置app:elevation="0dp"。一切都会好起来的。

    【讨论】:

      【解决方案5】:

      我尝试了以上所有方法,但没有一个适合我!

      然后我只需从 xml 中删除 AppBarLayout Widget。它解决了我的问题

      导致问题

       <android.support.design.widget.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:elevation="0dp">
      
          <android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@color/app_theme_black_color"
              local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
      </android.support.design.widget.AppBarLayout>
      

      已解决的问题(只需删除 AppBarLayout)

          <android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@color/app_theme_black_color"
              local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
      

      分享以改进。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-04
        • 2011-07-10
        • 2015-08-14
        • 1970-01-01
        • 2016-05-28
        • 1970-01-01
        • 2017-08-22
        • 1970-01-01
        相关资源
        最近更新 更多