Skip to content

Commit

Permalink
Adjust paddings to show NeumorphButton with drawable properly (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Aug 13, 2020
1 parent edf0baa commit be8ce6c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
7 changes: 5 additions & 2 deletions neumorphism/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

<style name="Widget.Neumorph" />

<style name="Widget.Neumorph.Button" parent="android:Widget">
<item name="android:padding">@dimen/design_default_padding</item>
<style name="Widget.Neumorph.Button" parent="Widget.AppCompat.Button">
<item name="android:textAppearance">?android:attr/textAppearanceButton</item>
<item name="android:minHeight">72dip</item>
<item name="android:minWidth">112dip</item>
<item name="android:paddingLeft">@dimen/design_btn_padding_left</item>
<item name="android:paddingRight">@dimen/design_btn_padding_right</item>
<item name="android:paddingTop">@dimen/design_btn_padding_top</item>
<item name="android:paddingBottom">@dimen/design_btn_padding_bottom</item>
<item name="android:stateListAnimator">@animator/button_state_list_anim_neumorph</item>
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
Expand Down
4 changes: 4 additions & 0 deletions neumorphism/src/main/res/values/values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

<!-- Default padding and inset to avoid shadow clipping -->
<dimen name="design_default_padding">12dp</dimen>
<dimen name="design_btn_padding_left">32dp</dimen>
<dimen name="design_btn_padding_right">32dp</dimen>
<dimen name="design_btn_padding_top">12dp</dimen>
<dimen name="design_btn_padding_bottom">12dp</dimen>
<dimen name="design_default_inset">12dp</dimen>

<!-- Default corner radius -->
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
dependencies {
implementation project(":neumorphism")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
10 changes: 10 additions & 0 deletions sample/src/main/res/drawable/ic_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorAccent"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M14.71,6.71c-0.39,-0.39 -1.02,-0.39 -1.41,0L8.71,11.3c-0.39,0.39 -0.39,1.02 0,1.41l4.59,4.59c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L10.83,12l3.88,-3.88c0.39,-0.39 0.38,-1.03 0,-1.41z" />
</vector>
10 changes: 10 additions & 0 deletions sample/src/main/res/drawable/ic_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorAccent"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M9.29,6.71c-0.39,0.39 -0.39,1.02 0,1.41L13.17,12l-3.88,3.88c-0.39,0.39 -0.39,1.02 0,1.41 0.39,0.39 1.02,0.39 1.41,0l4.59,-4.59c0.39,-0.39 0.39,-1.02 0,-1.41L10.7,6.7c-0.38,-0.38 -1.02,-0.38 -1.41,0.01z" />
</vector>
3 changes: 3 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="36dp"
android:drawablePadding="8dp"
android:text="Button"
app:drawableStartCompat="@drawable/ic_left"
app:drawableEndCompat="@drawable/ic_right"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/layout/activity_sample_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

<soup.neumorphism.NeumorphButton
android:id="@+id/button"
android:layout_width="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="Learn more"
Expand Down

0 comments on commit be8ce6c

Please sign in to comment.