android - TabLayout 透明度

标签 android android-layout android-studio android-tablayout

我目前正在创建一个应用程序并且出现了这个问题,我想让 TabLayout 透明。当我使用 RelativeLayout TabLayout 覆盖内容时,当我使用 LinearLayout TabLayout 背景不再透明。我该如何解决? 有一些图片和代码: RealitiveLayout LinearLayout

<?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>

最佳答案

为选项卡布局设置背景 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"/>

或者你可以给自定义背景稍微透明的颜色

1) 90% - 90 e.g android:background="#90000000"
2) 80% - 90 e.g android:background="#80000000"
3) 70% - 70 e.g android:background="#70000000"

关于android - TabLayout 透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48776812/

相关文章:

android 两个对话框-按下后退按钮时如何返回到上一个对话框

Android Wear 谷歌分析

java - Android效果波纹圆圈imageView

android - 如何滚动具有 3 个 ListView 的布局

android - Fragment 中的 notifyDataSetChanged() 不刷新 ListView

java - 单击后暂时交换按钮背景中的图像

java - 第二个 Activity 不会填充

java - Android Studio 运行时异常

android - 如何访问自定义资源目录下的资源文件?

android - 关于 Android Studio 中 calabash-android 支持的问题 : Ruby, Editing features and steps, Launching tests