2016-12-07 17 views
1

すべてのボディがあるが、このような丸いコーナータブを作成する方法を知っている:このようなアンドロイドで丸い角のタブを作成する方法は?

期待タブ: enter image description here

来るタブ: enter image description here をあなたはme.Thankにあなたを伝えることができると思います。

+0

使用hapeセレクタxmlとbanckgroundに設定 – Vinodh

+0

これは役に立ちます:http://stackoverflow.com/questions/8599755/rounded-corners-for-tabs-in-android –

+0

@Vinodh私は形状セレクタと次のタブ画像のような結果を使用しました予期した結果は表示されません。 – Fiend

答えて

0

@Vinodh私はViewPagerでTablayoutを使用します。私はTablayoutにスタイルを設定すると、このようなセレクタでtabBackgroundプロパティを設定します。

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:state_selected="true"> 
    <shape> 
     <corners android:topLeftRadius="8dp" android:topRightRadius="8dp"/> 
     <solid android:color="#fff"/> 
    </shape> 
</item> 

<item> 
    <layer-list> 
     <item> 
      <shape> 
       <corners android:topLeftRadius="8dp" android:topRightRadius="8dp"/> 
       <solid android:color="@color/white"/> 
      </shape> 
     </item> 
     <item> 
      <shape> 
       <corners android:radius="8dp"/> 
       <solid android:color="#000"/> 
      </shape> 
     </item> 

    </layer-list> 


</item> 

そしてTablayoutの背景設定:形状の下に試してみてください

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 

<corners android:topLeftRadius="8dp" android:topRightRadius="8dp"/> 
<solid android:color="#000"/> 

0

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > 
<corners 
android:radius="14dp" 
/> 
<gradient 
android:angle="45" 
android:centerX="35%" 
android:centerColor="#000000" 
android:startColor="#000000" 
android:endColor="#000000" 
android:type="linear" 
/> 
<padding 
android:left="0dp" 
android:top="0dp" 
android:right="0dp" 
android:bottom="0dp" 
/> 
<size 
android:width="270dp" 
android:height="60dp" 
/> 
<stroke 
android:width="3dp" 
android:color="#000000" 
/> 
</shape> 
関連する問題