Skip to content

Commit cf147c3

Browse files
committed
publish 1.1.2, support 'wrap_content' on item view.
1 parent 0329338 commit cf147c3

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ copy代码,或使用ADT的maven插件
1313
##### Android Studio / IDEA
1414
-`build.gradle`中添加
1515
```
16-
compile 'com.moxun:tagcloudlib:1.1.1'
16+
compile 'com.moxun:tagcloudlib:1.1.2'
1717
```
1818

1919
- 在布局文件中引入

app/src/main/java/com/moxun/tagcloud/TextTagsAdapter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.moxun.tagcloud;
22

3-
import android.app.Application;
43
import android.content.Context;
54
import android.support.annotation.NonNull;
65
import android.util.Log;
@@ -15,7 +14,6 @@
1514
import java.util.ArrayList;
1615
import java.util.Collections;
1716
import java.util.List;
18-
import java.util.Random;
1917

2018
/**
2119
* Created by moxun on 16/1/19.
@@ -37,8 +35,6 @@ public int getCount() {
3735
@Override
3836
public View getView(final Context context, final int position, ViewGroup parent) {
3937
TextView tv = new TextView(context);
40-
ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(200, 100);
41-
tv.setLayoutParams(lp);
4238
tv.setText("No." + position);
4339
tv.setGravity(Gravity.CENTER);
4440
tv.setOnClickListener(new View.OnClickListener() {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:orientation="horizontal" android:layout_width="30dp"
4-
android:layout_height="30dp"
3+
android:orientation="horizontal" android:layout_width="wrap_content"
4+
android:layout_height="wrap_content"
55
android:gravity="center_vertical">
66

77
<View
@@ -13,8 +13,8 @@
1313
android:layout_marginTop="4.5dp"/>
1414

1515
<ImageView
16-
android:layout_width="match_parent"
17-
android:layout_height="match_parent"
16+
android:layout_width="30dp"
17+
android:layout_height="30dp"
1818
android:src="@mipmap/android"/>
1919

2020
</FrameLayout>

tagcloudlib/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22
apply plugin: 'com.github.dcendents.android-maven'
33
apply plugin: 'com.jfrog.bintray'
44

5-
version = "1.1.1"
5+
version = "1.1.2"
66
android {
77
compileSdkVersion 23
88
buildToolsVersion "23.0.1"
@@ -43,7 +43,7 @@ install {
4343
}
4444
developers {
4545
developer {
46-
id 'misakuo' //填写开发者基本信息
46+
id 'misakuo' //开发者基本信息
4747
name 'moxun'
4848
email 'furmint@foxmail.com'
4949
}
@@ -77,10 +77,10 @@ artifacts {
7777
Properties properties = new Properties()
7878
File file = project.rootProject.file('local.properties')
7979
if(file != null && file.exists()) {
80-
println("Building on local machine......")
80+
println("\nBuilding on local machine......")
8181
properties.load(file.newDataInputStream())
8282
} else {
83-
println("Building on Travis......")
83+
println("\nBuilding on Travis......")
8484
properties.put("bintray.user",System.getenv("USER"))
8585
properties.put("bintray.apikey",System.getenv("TOKEN"))
8686
}

tagcloudlib/src/main/java/com/moxun/tagcloudlib/view/TagCloudView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ public void run() {
176176
removeAllViews();
177177
for (int i = 0; i < tagsAdapter.getCount(); i++) {
178178
TagCloudView.this.mTagCloud.add(new Tag(tagsAdapter.getPopularity(i)));
179-
addView(tagsAdapter.getView(getContext(), i, TagCloudView.this));
179+
View view = tagsAdapter.getView(getContext(), i, TagCloudView.this);
180+
addView(view);
180181
}
181182

182183
mTagCloud.create(true);
@@ -201,15 +202,15 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
201202
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
202203
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
203204

204-
measureChildren(widthMode, heightMode);
205-
206205
if (layoutParams == null) {
207206
layoutParams = (MarginLayoutParams) getLayoutParams();
208207
}
209208

210209
int dimensionX = widthMode == MeasureSpec.EXACTLY ? contentWidth : minSize - layoutParams.leftMargin - layoutParams.rightMargin;
211210
int dimensionY = heightMode == MeasureSpec.EXACTLY ? contentHeight : minSize - layoutParams.leftMargin - layoutParams.rightMargin;
212211
setMeasuredDimension(dimensionX, dimensionY);
212+
213+
measureChildren(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
213214
}
214215

215216
@Override

0 commit comments

Comments
 (0)