Skip to content

Commit

Permalink
2.0 demo updated
Browse files Browse the repository at this point in the history
  • Loading branch information
woxingxiao committed Oct 25, 2017
1 parent 5ef9370 commit e11101b
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 9 deletions.
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xw.sample.vectorcompattextview"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
targetSdkVersion 26
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
Expand All @@ -24,7 +25,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
testCompile 'junit:junit:4.12'
compile project(':vectorcompattextview')
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
package com.xw.sample.vectorcompattextview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.xw.repo.VectorCompatTextView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final VectorCompatTextView textView = (VectorCompatTextView) findViewById(R.id.checkable_text_view);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
textView.toggle();
textView.setText(textView.isChecked() ? "SELECTED TAB" : "UNSELECTED TAB");
}
});
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/selector_drawable_tab.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/shape_rect_solid_gray"
android:state_checked="false"/>
<item
android:drawable="@drawable/shape_rect_solid_red"
android:state_checked="true"/>
</selector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/selector_text_color_tab.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@color/color_gray"
android:state_checked="false"/>
<item
android:color="@color/color_red"
android:state_checked="true"/>
</selector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/shape_rect_solid_gray.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_gray"/>
</shape>
24 changes: 22 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="微博"
Expand All @@ -47,6 +48,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="微信"
Expand All @@ -57,6 +59,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="twitter"
Expand Down Expand Up @@ -185,6 +188,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="GitHub"
Expand All @@ -196,6 +200,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="你好"
Expand Down Expand Up @@ -231,6 +236,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="GitHub"
Expand All @@ -242,6 +248,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="Android"
Expand All @@ -254,6 +261,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:orientation="horizontal">

Expand All @@ -268,14 +276,26 @@
app:drawableWidth="4dp"/>

<com.xw.repo.VectorCompatTextView
android:layout_width="wrap_content"
android:id="@+id/checkable_text_view"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:checked="true"
android:drawablePadding="4dp"
android:gravity="center"
android:text="SELECTED TAB"
android:textColor="@drawable/selector_text_color_tab"
app:drawableAdjustTextWidth="true"
app:drawableBottomCompat="@drawable/shape_rect_solid_red"
app:drawableBottomCompat="@drawable/selector_drawable_tab"
app:drawableHeight="2dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="← click it"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Binary file removed screenshot/demo3.png
Binary file not shown.
Binary file added screenshot/demo4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e11101b

Please sign in to comment.