change switch to material switch

only-core-features
Felix Prahl-Kamps 2019-10-22 15:56:45 +02:00
parent 9ab170c05b
commit cc6ee5b7ad
3 changed files with 12 additions and 11 deletions

View File

@ -7,18 +7,19 @@ import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.material.switchmaterial.SwitchMaterial;
import lu.circl.mispbump.R; import lu.circl.mispbump.R;
public class MaterialPreferenceSwitch extends ConstraintLayout { public class MaterialPreferenceSwitch extends ConstraintLayout {
private TextView titleView, subTitleView; private TextView titleView, subTitleView;
private Switch switchView; private SwitchMaterial switchView;
private CompoundButton.OnCheckedChangeListener onCheckedChangeListener; private CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
public MaterialPreferenceSwitch(Context context, AttributeSet attrs) { public MaterialPreferenceSwitch(Context context, AttributeSet attrs) {

View File

@ -33,7 +33,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="4dp"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false" android:focusableInTouchMode="false"
@ -41,18 +41,16 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/material_preference_switch" app:layout_constraintEnd_toStartOf="@id/material_preference_switch"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/material_preference_title" app:layout_constraintTop_toBottomOf="@+id/material_preference_title"
tools:text="Subtitle" /> tools:text="Subtitle" />
<Switch <com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/material_preference_switch" android:id="@+id/material_preference_switch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="@id/material_preference_subtitle" app:layout_constraintBottom_toBottomOf="@id/material_preference_subtitle"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/material_preference_title"/> app:layout_constraintTop_toTopOf="@id/material_preference_title" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,9 +1,11 @@
<resources> <resources>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/white</item>
<item name="colorSecondary">@color/colorSecondary</item> <item name="colorSecondary">@color/colorSecondary</item>
<item name="colorOnSecondary">@color/colorOnSecondary</item> <item name="colorOnSecondary">@color/colorOnSecondary</item>
@ -29,11 +31,11 @@
<style name="AppTheme.TextAppearance.ListTitle"> <style name="AppTheme.TextAppearance.ListTitle">
<item name="android:textColor">#de000000</item> <item name="android:textColor">#de000000</item>
<item name="android:textSize">16dp</item> <item name="android:textSize">16sp</item>
</style> </style>
<style name="AppTheme.TextAppearance.ListSubtitle"> <style name="AppTheme.TextAppearance.ListSubtitle">
<item name="android:textColor">#99000000</item> <item name="android:textColor">#99000000</item>
<item name="android:textSize">14dp</item> <item name="android:textSize">14sp</item>
</style> </style>
</resources> </resources>