diff --git a/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java b/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java
index 0387a21..8436332 100644
--- a/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java
+++ b/app/src/main/java/com/github/xiaogegechen/trackview/MainActivity.java
@@ -5,14 +5,14 @@
import android.util.Log;
import android.view.View;
import android.widget.TextView;
+import android.widget.Toast;
import com.github.xiaogegechen.library.TrackView;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
-
- private boolean state = false;
+ private int num = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -22,7 +22,6 @@ protected void onCreate(Bundle savedInstanceState) {
final TrackView trackView = findViewById (R.id.track_view);
final TextView textView = findViewById (R.id.text_view);
-
textView.setOnClickListener (new View.OnClickListener () {
@Override
public void onClick(View v) {
@@ -33,16 +32,30 @@ public void onClick(View v) {
trackView.setOnClickListener (new View.OnClickListener () {
@Override
public void onClick(View v) {
+ textView.setText ("WORLD");
+ Toast.makeText (MainActivity.this, "click", Toast.LENGTH_SHORT).show ();
+ }
+ });
- TrackView.Position position = trackView.getPosition ();
- Log.d (TAG, "onClick: " + position);
+ findViewById (R.id.close).setOnClickListener (new View.OnClickListener () {
+ @Override
+ public void onClick(View v) {
+ trackView.close ();
+ }
+ });
- if(!state){
- trackView.close ();
- }else{
- trackView.open ();
- }
- state = !state;
+ findViewById (R.id.open).setOnClickListener (new View.OnClickListener () {
+ @Override
+ public void onClick(View v) {
+ trackView.open ();
+ }
+ });
+
+ findViewById (R.id.change).setOnClickListener (new View.OnClickListener () {
+ @Override
+ public void onClick(View v) {
+ trackView.setText ("num:"+num);
+ num++;
}
});
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 74849a4..9527729 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -3,8 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#00FFFFFF"
android:layout_width="match_parent"
+ android:orientation="vertical"
android:layout_height="match_parent">
-
+
+
+
+
+
+ android:padding="3dp"
+ android:layout_margin="30dp"
+ app:inner_text="下一个回答"/>
\ No newline at end of file
diff --git a/library/src/main/java/com/github/xiaogegechen/library/TrackView.java b/library/src/main/java/com/github/xiaogegechen/library/TrackView.java
index 209ad51..9f3c946 100644
--- a/library/src/main/java/com/github/xiaogegechen/library/TrackView.java
+++ b/library/src/main/java/com/github/xiaogegechen/library/TrackView.java
@@ -15,7 +15,6 @@
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -26,8 +25,6 @@
*/
public class TrackView extends View {
- private static final String TAG = "TrackView";
-
// 默认大小
private static final int SIZE_DEFAULT = 50;
@@ -38,7 +35,7 @@ public class TrackView extends View {
private static final int GO_TO_BOUNDARY_INTERVAL_DEFAULT = 100;
// 合上的默认时长
- private static final int CLOSE_INTERVAL_DEFAULT = 500;
+ private static final int CLOSE_INTERVAL_DEFAULT = 200;
// 默认控件活动边界留白
private static final int BLANK_LEFT_DEFAULT = 10;
@@ -47,13 +44,13 @@ public class TrackView extends View {
private static final int BLANK_BOTTOM_DEFAULT = 10;
// 默认外围线条的颜色
- private static final int OUT_STROKE_COLOR_DEFAULT = Color.BLACK;
+ private static final int OUT_STROKE_COLOR_DEFAULT = Color.parseColor ("#4A000000");
// 默认的外围线宽
private static final int OUT_STROKE_WIDTH_DEFAULT = 1;
// 默认的内部线宽
- private static final int IN_STROKE_WIDTH_DEFAULT = 1;
+ private static final int IN_STROKE_WIDTH_DEFAULT = 2;
// 默认内部线条的颜色
private static final int IN_STROKE_COLOR_DEFAULT = Color.BLACK;
@@ -535,7 +532,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
}
// 改变view大小
- setLayoutParams (params);
+ requestLayout ();
}
};
}
@@ -601,7 +598,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
}
// 改变view大小
- setLayoutParams (params);
+ requestLayout ();
}
};
}