Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaogegeChen committed May 22, 2019
1 parent 2a4cf93 commit b7c6047
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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++;
}
});

Expand Down
44 changes: 25 additions & 19 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,40 @@
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">

<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="HELLO"
android:textSize="50sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/open"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="展开"/>
<Button
android:id="@+id/close"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="关闭"/>
<Button
android:id="@+id/change"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="改变文字"/>
</LinearLayout>
<com.github.xiaogegechen.library.TrackView
android:padding="3dp"
android:layout_marginLeft="10dp"
android:id="@+id/track_view"
android:layout_marginTop="30dp"
android:layout_width="200dp"
android:layout_width="150dp"
android:layout_height="50dp"
app:inner_distance="8dp"
app:inner_length="10dp"
app:inner_stroke_width="1dp"
app:blank_bottom="15dp"
app:blank_left="8dp"
app:blank_right="8dp"
app:blank_top="30dp"
app:inner_content_color="#ffffff"
app:inner_stroke_color="#000000"
app:out_stroke_color="#000000"
app:out_stroke_width="1dp"
app:inner_text_size="30sp"
app:inner_text_color="@color/colorAccent"
app:inner_text="hello"/>
android:padding="3dp"
android:layout_margin="30dp"
app:inner_text="下一个回答"/>
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,8 +25,6 @@
*/
public class TrackView extends View {

private static final String TAG = "TrackView";

// 默认大小
private static final int SIZE_DEFAULT = 50;

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -535,7 +532,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
}

// 改变view大小
setLayoutParams (params);
requestLayout ();
}
};
}
Expand Down Expand Up @@ -601,7 +598,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
}

// 改变view大小
setLayoutParams (params);
requestLayout ();
}
};
}
Expand Down

0 comments on commit b7c6047

Please sign in to comment.