build.gradle (Project: MyApplication)
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 |
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url "https://jitpack.io" } } } task clean(type: Delete) { delete rootProject.buildDir } |
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.shts:TriangleLabelView:1.1.2' 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/styles.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<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="frameStyle"> <item name="android:layout_width">130dp</item> <item name="android:layout_height">130dp</item> <item name="android:layout_margin">5dp</item> </style> <style name="imageViewStyle"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">match_parent</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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
<?xml version="1.0" encoding="utf-8"?> <GridLayout 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:columnCount="2" android:scrollbars="none" tools:context=".MainActivity" tools:showIn="@layout/activity_main"> <FrameLayout style="@style/frameStyle"> <ImageView style="@style/imageViewStyle" android:src="@drawable/android" /> <jp.shts.android.library.TriangleLabelView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="top|left" app:backgroundColor="#f00" app:corner="leftTop" app:primaryText="10%" app:primaryTextColor="#fff" app:primaryTextSize="14sp" app:secondaryText="ลด" app:secondaryTextColor="#fff" app:secondaryTextSize="12sp" /> </FrameLayout> <FrameLayout style="@style/frameStyle"> <ImageView style="@style/imageViewStyle" android:src="@drawable/android" /> <jp.shts.android.library.TriangleLabelView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="top|right" app:backgroundColor="#f00" app:corner="rightTop" app:primaryText="Seller" app:primaryTextColor="#fff" app:primaryTextSize="12sp" app:secondaryText="Best" app:secondaryTextColor="#fff" app:secondaryTextSize="10sp" /> </FrameLayout> <FrameLayout style="@style/frameStyle"> <ImageView style="@style/imageViewStyle" android:src="@drawable/android" /> <jp.shts.android.library.TriangleLabelView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom|left" app:backgroundColor="#f00" app:corner="leftBottom" app:primaryText="New" app:primaryTextColor="#fff" app:primaryTextSize="12sp" /> </FrameLayout> <FrameLayout style="@style/frameStyle"> <ImageView style="@style/imageViewStyle" android:src="@drawable/android" /> <jp.shts.android.library.TriangleLabelView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom|right" app:backgroundColor="#f00" app:corner="rightBottom" app:primaryText="Hot" app:primaryTextColor="#fff" app:primaryTextSize="12sp" /> </FrameLayout> </GridLayout> |