2015-06-25 53 views
0

我正在使用視圖尋呼機,fragmentpageradapter,並在我的android應用程序滑動選項卡布局..我期待設置不透明度我的滑動選項卡布局,以便您可以部分看到背景中的可滾動內容 - 我想有這個模糊,但我一次只採取一步。現在,當我將不透明度分配給我的xml背景顏色時,它將不透明度分配給我的圖標,而不是圖標背後的背景。我該如何解決這個問題?將不透明度設置爲滑動標籤佈局?

這裏是我的xml:

<wxyc.wxyc_consolidate.TabLayoutTools.SlidingTabLayout 
    android:id="@+id/sliding_tabs" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_below="@id/wxyc" 
    android:layout_gravity="center" 
    android:background="#ffcbcbcb" 
    android:gravity="center" 
    android:layout_alignParentBottom="true" 
    /> 

這裏就是我實現slidingTabs:

MyFragmentPagerAdapter fragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), 
      MainActivity.this, liveStreamFragment); 

    // getSupportFragmentManager allows use to interact with the fragments 
    // MyFragmentPagerAdapter will return a fragment based on an index that is passed 
    viewPager.setAdapter(fragmentPagerAdapter); 

    // Initialize the Sliding Tab Layout 
    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); 
    slidingTabLayout.setCustomTabView(R.layout.custom_tab, 0); 
    slidingTabLayout.setDistributeEvenly(true); 
    slidingTabLayout.setBackgroundColor(Color.rgb(202, 202, 212)); 


    slidingTabLayout.setFillViewport(true); 
    slidingTabLayout.setViewPager(viewPager); 

    slidingTabLayout.setViewPager(viewPager); 

回答

1

第2個十六進制數字的背景是不透明。如果您想要半透明背景,請將它們設置爲小於ff

如果您想在後臺查看,您還需要讓SlidingTabLayoutViewPager重疊。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@android:color/white"/> 
    <com.example.android.common.view.SlidingTabLayout 
     android:id="@+id/sliding_tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="#aacbcbcb"/> 
</RelativeLayout> 
+0

我的看法完全尋呼機現在消失.. @Karaokyo –

+0

我父母匹配的高度和類型的FrameLayout的父視圖組擁有它。你是一樣的嗎? – tachyonflux

+0

我懂了!我只需在我的java代碼中刪除我的顏色分配。儘管現在我的標籤欄位於頂部,我無法將它固定在底部。爲什麼是這樣? –