Android 如何设置表格布局透明,使图标和文本保持白色
这是我在这里的第一个问题,但我以前做过很多研究。 因此,我是Android开发的新手,正在尝试设计一个基于新的ViewPager和Tablayout的自定义登录/签名活动。 问题是,我试图为我的两个选项卡AppBarLayout设置一个透明背景,但找不到任何适合我的东西。 我尝试了很多张贴的解决方案,但似乎没有人适合我的情况。 最后一个是张贴在这里的: 但没什么,我能得到的最好的东西是这样的: 以下是获得以下内容的布局代码:Android 如何设置表格布局透明,使图标和文本保持白色,android,xml,layout,android-tablayout,android-appbarlayout,Android,Xml,Layout,Android Tablayout,Android Appbarlayout,这是我在这里的第一个问题,但我以前做过很多研究。 因此,我是Android开发的新手,正在尝试设计一个基于新的ViewPager和Tablayout的自定义登录/签名活动。 问题是,我试图为我的两个选项卡AppBarLayout设置一个透明背景,但找不到任何适合我的东西。 我尝试了很多张贴的解决方案,但似乎没有人适合我的情况。 最后一个是张贴在这里的: 但没什么,我能得到的最好的东西是这样的: 以下是获得以下内容的布局代码: <?xml version="1.0" encoding="
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/imageView2"
android:layout_gravity="left|center_horizontal"
android:background="#f2a0ef"
android:contentDescription="@string/logDesc" />
<RelativeLayout
android:layout_width="340dp"
android:layout_height="match_parent"
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="-102dp"
android:theme="@style/MyMaterialTheme"
android:layout_marginBottom="80dp"
android:transitionGroup="false">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@android:color/transparent">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIndicatorHeight="4dp"
android:background="@android:color/transparent"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="false"
android:layout_below="@+id/appBarLayout"
android:background="#ffffff" />
</RelativeLayout>
</LinearLayout>
我认为不需要活动代码,如果需要,请告诉我。
问题是,我几乎已经明白了,但是围绕标签的效果当然不是我想要的。
我真的被这件事缠住了,不想在完成这件事之前继续做下去。
提前谢谢 在AppBarLayout外部使用TabLayout
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@android:color/transparent"
>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIndicatorHeight="4dp"
android:background="@android:color/transparent"
/>
我太蠢了,这种奇怪的行为来自appBarLAyout小部件的阴影(如果设置为高于任何值),因为设置选项卡的透明度会使其下降一个奇怪的阴影,因此需要2天的时间来尝试使其工作,a必须做的唯一一件事是将小部件的高度设置为“0dp” 这是最终代码:
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/imageView2"
android:layout_gravity="left|center_horizontal"
android:background="#f2a0ef"
android:contentDescription="@string/logDesc" />
<RelativeLayout
android:layout_width="340dp"
android:layout_height="match_parent"
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="-102dp"
android:theme="@style/MyMaterialTheme"
android:layout_marginBottom="80dp"
android:transitionGroup="false">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@android:color/transparent"
**app:elevation="0dp"**
>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIndicatorHeight="4dp"
android:background="@android:color/transparent"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="false"
android:layout_below="@+id/appBarLayout"
android:background="#ffffff" />
</RelativeLayout>
</LinearLayout>
谢谢