代码之家  ›  专栏  ›  技术社区  ›  Alexei

无法在tablayout顶部隐藏行

  •  0
  • Alexei  · 技术社区  · 4 年前

    Android Studio 3.5

    我想显示底部有阴影的Tablayout。 所以我试试这个:

    <?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">
    
        <include layout="@layout/appbar" />
    
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/background"
            android:orientation="vertical">
    
            <android.support.v7.widget.CardView
                android:id="@+id/balanceTitleContainer"
                style="@style/ImpressiveCard"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/default_gap"
                android:layout_marginEnd="@dimen/default_gap">
    
                <LinearLayout
                    android:id="@+id/baseTokenContainer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
    
    
                    <TextView
                        android:id="@+id/baseTokenTokenView"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:textSize="19sp"
                        android:textStyle="bold" />
    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/default_gap"
                        android:gravity="center"
                        android:orientation="horizontal">
    
                        <Button
                            android:id="@+id/topUpButton"
                            style="@style/PrimaryButton"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginEnd="2dp"
                            android:layout_weight="0.5"
                            android:text="@string/topUp"
                            android:textSize="12sp"
                            android:theme="@style/PrimaryButton.Overlay" />
    
                        <Button
                            android:id="@+id/sendButton"
                            style="@style/PrimaryButton"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="2dp"
                            android:layout_weight="0.5"
                            android:text="@string/send"
                            android:textSize="12sp"
                            android:theme="@style/PrimaryButton.Overlay" />
                    </LinearLayout>
                </LinearLayout>
            </android.support.v7.widget.CardView>
    
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:elevation="@dimen/line_divider_shadow_height"
                app:tabMode="scrollable"
                app:tabTextColor="@color/colorAccent">
    
                <android.support.design.widget.TabItem
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/my_vauchers" />
    
            </android.support.design.widget.TabLayout>
    

    appbar布局xml:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/appbar"
        style="@style/AppbarTheme"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <include layout="@layout/toolbar" />
    
    </android.support.design.widget.AppBarLayout>
    

    我使用

    android:background="@color/white"
                   android:elevation="@dimen/line_divider_shadow_height"
    

    显示阴影。

    enter image description here

    正如您在表格中看到的,顶部(上图)也显示了灰色线 我的情人

    0 回复  |  直到 4 年前