2017-07-27 2 views
-1

ich die TabLayout wie diese implementiert werden sollen:Machen runde Ecke TabLayout TabItem android

TabLayout like this

+1

Hallo @AzimShaikh und begrüßen Überlauf zu stapeln. Bitte nehmen Sie sich einen Moment Zeit, um die folgenden Anleitungen zu lesen: Wie Sie Fragen stellen und Beispiele ausführen –

+0

Werfen Sie einen Blick auf die [Hilfe]. – Ares

Antwort

1

erstellen button ähnliche

<Button 
    android:id="@+id/cancelSOSButton" 
    android:layout_width="wrap_content" 
    android:layout_height="40dp" 
    android:layout_gravity="bottom" 
    android:text="GAMES" 
    android:layout_marginLeft="10dp" 
    android:textColor="@color/whiteTextColor" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/round_corners_green" 
    android:textSize="18sp"/> 

Dann erstellen Sie eine XML Datei in drawable Ordner mit dem Namen round_corners_green.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="@color/green"/> 
    <stroke android:width="0dip"/> 
    <corners android:radius="15dip"/> 
    <padding 
     android:bottom="0dip" 
     android:left="0dip" 
     android:right="0dip" 
     android:top="0dip"/> 
</shape> 

in Colors.xml diese Farbe

<color name="green">#3cb879</color> 

Ähnlich fügen Sie Schaltflächen wie diese erstellen können.

Ergebnisausgabe

Screen

0

Versuchen Sie, diese

eine xml erstellen (rounded_corner_button.xml) in ziehbar

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape 
      android:shape="rectangle"> 
      <solid 
       android:color="@color/btn_green"/> 
      <stroke 
       android:color="@color/btn_green" 
       android:width="2dp" /> 
      <corners 
       android:radius="15dp" /> 
     </shape> 
    </item> 
</selector> 

Dann rufen Sie es in Ihrem Button als Hintergrund

android:background="@drawable/rounded_corner_button" 
1

ziehbar Machen tab_background.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<corners 
    android:bottomLeftRadius="15dp" 
    android:bottomRightRadius="15dp" 
    android:topLeftRadius="15dp" 
    android:topRightRadius="15dp" /> 

<stroke 
    android:width="10dp" 
    android:color="@android:color/transparent"></stroke> 

<solid android:color="#23cf5a" /> 

</shape> 

Tab-Layout wie wie unten

<android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     app:tabBackground="@drawable/tab_background" 
     app:tabGravity="fill" 
     app:tabMode="scrollable" 
     android:layout_margin="5dp" 
     app:tabSelectedTextColor="#FFFFFF" 
     android:clipToPadding="false" 
     app:tabPaddingStart="10dp" 
     app:tabPaddingEnd="10dp" 
     app:tabIndicatorHeight="0dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

Ausgabe

enter image description here

+0

Es verwendet TabLayout mit TabItem @AzimShaikh , Es könnte Ihnen helfen. –

Verwandte Themen