Created
July 12, 2020 23:48
-
-
Save DjangoLC/5dc0051c701831aeddf192b55cce69ef to your computer and use it in GitHub Desktop.
custom switch layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout 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:id="@+id/custom_switch_container" | |
android:layout_width="222dp" | |
android:layout_height="33dp" | |
android:background="@drawable/shape" | |
android:backgroundTint="#82BC00" | |
android:clickable="true" | |
android:orientation="horizontal"> | |
<androidx.appcompat.widget.AppCompatButton | |
android:id="@+id/imgShape" | |
android:layout_width="wrap_content" | |
android:layout_height="30dp" | |
android:layout_gravity="center|start" | |
android:layout_marginStart="4dp" | |
android:layout_marginLeft="4dp" | |
android:layout_marginEnd="4dp" | |
android:background="@drawable/shape" | |
android:clickable="false" | |
app:layout_constraintBottom_toBottomOf="parent" | |
tools:layout_editor_absoluteX="95dp" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:elevation="10dp"> | |
<TextView | |
android:id="@+id/tvOn" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:padding="4dp" | |
android:text="@string/off" | |
android:textColor="#80000000" | |
android:textStyle="bold" /> | |
<TextView | |
android:id="@+id/tvOff" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_marginStart="12dp" | |
android:layout_marginLeft="12dp" | |
android:layout_weight="1" | |
android:gravity="center" | |
android:paddingStart="8dp" | |
android:paddingLeft="8dp" | |
android:paddingTop="4dp" | |
android:paddingEnd="8dp" | |
android:paddingBottom="4dp" | |
android:text="@string/on" | |
android:textColor="@android:color/white" | |
android:textStyle="bold" /> | |
</LinearLayout> | |
</FrameLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment