Skip to content

Commit

Permalink
新增展开合并、显示文字功能
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaogegeChen committed May 22, 2019
1 parent 87b3905 commit 2a4cf93
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
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;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
Expand All @@ -21,6 +22,7 @@ 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 @@ -31,8 +33,16 @@ public void onClick(View v) {
trackView.setOnClickListener (new View.OnClickListener () {
@Override
public void onClick(View v) {
textView.setText ("WORLD");
Toast.makeText (MainActivity.this, "点击了拖动按钮", Toast.LENGTH_SHORT).show ();

TrackView.Position position = trackView.getPosition ();
Log.d (TAG, "onClick: " + position);

if(!state){
trackView.close ();
}else{
trackView.open ();
}
state = !state;
}
});

Expand Down
19 changes: 13 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#00FFFFFF"
android:layout_width="match_parent"
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:textSize="50sp"
android:text="HELLO"/>
android:text="HELLO"
android:textSize="50sp" />
<com.github.xiaogegechen.library.TrackView
android:padding="3dp"
android:layout_marginLeft="10dp"
android:id="@+id/track_view"
android:layout_marginTop="50dp"
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_marginTop="30dp"
android:layout_width="200dp"
android:layout_height="50dp"
app:inner_distance="8dp"
app:inner_length="10dp"
app:inner_stroke_width="1dp"
Expand All @@ -25,5 +28,9 @@
app:blank_top="30dp"
app:inner_content_color="#ffffff"
app:inner_stroke_color="#000000"
app:out_stroke_width="1dp"/>
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"/>
</FrameLayout>
Loading

0 comments on commit 2a4cf93

Please sign in to comment.