build.gradle (Module: app)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "com.phaisarn.myapplication" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.github.siyamed:android-shape-imageview:0.9.+@aar' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } |
values/colors.xml
1 2 3 4 5 6 |
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#3F51B5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#FF4081</color> </resources> |
values/styles.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="shapeStyle"> <item name="android:layout_width">130dp</item> <item name="android:layout_height">130dp</item> <item name="android:layout_margin">10dp</item> </style> </resources> |
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<?xml version="1.0" encoding="utf-8"?> <ScrollView 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:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|center_horizontal" android:layout_margin="20dp" android:scrollbars="none" tools:context=".MainActivity" tools:showIn="@layout/activity_main"> <GridLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:columnCount="2"> <com.github.siyamed.shapeimageview.CircularImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="3dp" /> <com.github.siyamed.shapeimageview.RoundedImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" app:siRadius="20dp" /> <com.github.siyamed.shapeimageview.PentagonImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" /> <com.github.siyamed.shapeimageview.HexagonImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" /> <com.github.siyamed.shapeimageview.HeartImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" /> <com.github.siyamed.shapeimageview.StarImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" /> <com.github.siyamed.shapeimageview.BubbleImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" /> <com.github.siyamed.shapeimageview.DiamondImageView style="@style/shapeStyle" android:src="@drawable/flower" app:siBorderColor="@android:color/darker_gray" app:siBorderWidth="0dp" /> </GridLayout> </ScrollView> |
ภาพที่ใช้
Link