Reputation: 115
I'm creating an app currently and this issue occurred, I want to make TabLayout
transparent. When I use RelativeLayout
TabLayout
covers content, when I use LinearLayout
TabLayout
background becomes not transparent anymore. How could I solve?
There are some images and code:
<?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"
tools:context="com.example.android.news.MainActivity"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:background="#67000000"
app:tabTextColor="#ffffff"
android:layout_height="wrap_content"
app:tabSelectedTextColor="@color/colorAccent"
app:tabMode="fixed" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Upvotes: 1
Views: 1333
Reputation: 7948
Set background to tab layouts android:background="@android:color/transparent"
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:hapticFeedbackEnabled="true"/>
or you can give custom background slightly transparent colour
1) 90% - 90 e.g android:background="#90000000"
2) 80% - 90 e.g android:background="#80000000"
3) 70% - 70 e.g android:background="#70000000"
Upvotes: 1