-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
238 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/src/main/java/com/dl7/taglayout/TagReverseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.dl7.taglayout; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.dl7.tag.TagLayout; | ||
import com.dl7.tag.TagView; | ||
import com.dl7.taglayout.utils.TagWordFactory; | ||
import com.dl7.taglayout.utils.ToastUtils; | ||
|
||
public class TagReverseActivity extends AppCompatActivity implements TagView.OnTagClickListener, TagView.OnTagLongClickListener { | ||
|
||
private TagLayout mTagLayout1; | ||
private TagLayout mTagLayout2; | ||
private TagLayout mTagLayout3; | ||
private TagView mTagDel; | ||
private TagView mTagAdd; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_tag_reverse); | ||
initView(); | ||
} | ||
|
||
private void initView() { | ||
mTagLayout1 = (TagLayout) findViewById(R.id.tag_layout_1); | ||
mTagLayout2 = (TagLayout) findViewById(R.id.tag_layout_2); | ||
mTagLayout3 = (TagLayout) findViewById(R.id.tag_layout_3); | ||
mTagDel = (TagView) findViewById(R.id.tag_del); | ||
mTagAdd = (TagView) findViewById(R.id.tag_add); | ||
mTagLayout1.setTagClickListener(this); | ||
mTagLayout1.setTagLongClickListener(this); | ||
mTagLayout2.setTagClickListener(this); | ||
mTagLayout2.setTagLongClickListener(this); | ||
mTagLayout3.setTagClickListener(this); | ||
mTagLayout3.setTagLongClickListener(this); | ||
|
||
mTagAdd.setTagClickListener(new TagView.OnTagClickListener() { | ||
@Override | ||
public void onTagClick(int position, String text, @TagView.TagMode int tagMode) { | ||
String word = TagWordFactory.provideTagWord(); | ||
mTagLayout1.addTag(word); | ||
mTagLayout2.addTag(word); | ||
mTagLayout3.addTag(word); | ||
} | ||
}); | ||
mTagDel.setTagClickListener(new TagView.OnTagClickListener() { | ||
@Override | ||
public void onTagClick(int position, String text, @TagView.TagMode int tagMode) { | ||
mTagLayout1.deleteTag(0); | ||
mTagLayout2.deleteTag(0); | ||
mTagLayout3.deleteTag(0); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onTagClick(int position, String text, @TagView.TagMode int tagMode) { | ||
ToastUtils.showToast(text); | ||
} | ||
|
||
@Override | ||
public void onTagLongClick(int position, String text, @TagView.TagMode int tagMode) { | ||
ToastUtils.showToast("长按:" + text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
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="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context="com.dl7.taglayout.TagReverseActivity"> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_weight="1"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:text="圆角矩形(彩色、一行固定3个):" | ||
android:layout_margin="3dp" | ||
android:layout_height="wrap_content"/> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginBottom="2dp" | ||
android:layout_marginTop="2dp" | ||
android:background="#dddddd"/> | ||
|
||
<com.dl7.tag.TagLayout | ||
android:id="@+id/tag_layout_1" | ||
style="@style/TagLayout.RandomColor" | ||
app:tag_layout_fit_num="3" | ||
app:tag_layout_horizontal_reverse="true" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:text="圆弧形(按压效果):" | ||
android:layout_margin="3dp" | ||
android:layout_height="wrap_content"/> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginBottom="2dp" | ||
android:layout_marginTop="2dp" | ||
android:background="#dddddd"/> | ||
|
||
<com.dl7.tag.TagLayout | ||
android:id="@+id/tag_layout_2" | ||
style="@style/TagLayout.Arc" | ||
app:tag_layout_press_feedback="true" | ||
app:tag_layout_horizontal_reverse="true" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:text="直角矩形(彩色):" | ||
android:layout_margin="3dp" | ||
android:layout_height="wrap_content"/> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginBottom="2dp" | ||
android:layout_marginTop="2dp" | ||
android:background="#dddddd"/> | ||
|
||
<com.dl7.tag.TagLayout | ||
android:id="@+id/tag_layout_3" | ||
style="@style/TagLayout.Rect" | ||
app:tag_layout_random_color="true" | ||
app:tag_layout_horizontal_reverse="true" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> | ||
</LinearLayout> | ||
|
||
</ScrollView> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:background="#dddddd"/> | ||
|
||
<FrameLayout | ||
android:layout_width="match_parent" | ||
android:padding="5dp" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.dl7.tag.TagView | ||
android:id="@+id/tag_del" | ||
android:layout_width="80dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="20dp" | ||
app:tag_text="删除" | ||
app:tag_border_color="@android:color/holo_red_light" | ||
app:tag_bg_color="@android:color/white" | ||
app:tag_bg_color_check="@android:color/holo_red_light" | ||
app:tag_border_color_check="@android:color/holo_red_light" | ||
app:tag_text_color_check="@android:color/white" | ||
app:tag_icon="@mipmap/ic_delete" | ||
app:tag_press_feedback="true" | ||
app:tag_text_color="@android:color/holo_red_light"/> | ||
|
||
<com.dl7.tag.TagView | ||
android:id="@+id/tag_add" | ||
android:layout_width="80dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="right" | ||
android:layout_marginRight="20dp" | ||
app:tag_text="添加" | ||
app:tag_border_color="@android:color/holo_green_light" | ||
app:tag_bg_color="@android:color/white" | ||
app:tag_bg_color_check="@android:color/holo_green_light" | ||
app:tag_border_color_check="@android:color/holo_green_light" | ||
app:tag_text_color_check="@android:color/white" | ||
app:tag_icon="@mipmap/ic_add" | ||
app:tag_press_feedback="true" | ||
app:tag_text_color="@android:color/holo_green_light"/> | ||
</FrameLayout> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters