Skip to content

Commit

Permalink
publish 1.1.2, support 'wrap_content' on item view.
Browse files Browse the repository at this point in the history
  • Loading branch information
misakuo committed Mar 7, 2016
1 parent 0329338 commit cf147c3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -13,7 +13,7 @@ copy代码,或使用ADT的maven插件
##### Android Studio / IDEA
-`build.gradle`中添加
```
compile 'com.moxun:tagcloudlib:1.1.1'
compile 'com.moxun:tagcloudlib:1.1.2'
```

- 在布局文件中引入
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/com/moxun/tagcloud/TextTagsAdapter.java
@@ -1,6 +1,5 @@
package com.moxun.tagcloud;

import android.app.Application;
import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;
Expand All @@ -15,7 +14,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
* Created by moxun on 16/1/19.
Expand All @@ -37,8 +35,6 @@ public int getCount() {
@Override
public View getView(final Context context, final int position, ViewGroup parent) {
TextView tv = new TextView(context);
ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(200, 100);
tv.setLayoutParams(lp);
tv.setText("No." + position);
tv.setGravity(Gravity.CENTER);
tv.setOnClickListener(new View.OnClickListener() {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/tag_item_view.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="30dp"
android:layout_height="30dp"
android:orientation="horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">

<View
Expand All @@ -13,8 +13,8 @@
android:layout_marginTop="4.5dp"/>

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/android"/>

</FrameLayout>
8 changes: 4 additions & 4 deletions tagcloudlib/build.gradle
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.1.1"
version = "1.1.2"
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
Expand Down Expand Up @@ -43,7 +43,7 @@ install {
}
developers {
developer {
id 'misakuo' //填写开发者基本信息
id 'misakuo' //开发者基本信息
name 'moxun'
email 'furmint@foxmail.com'
}
Expand Down Expand Up @@ -77,10 +77,10 @@ artifacts {
Properties properties = new Properties()
File file = project.rootProject.file('local.properties')
if(file != null && file.exists()) {
println("Building on local machine......")
println("\nBuilding on local machine......")
properties.load(file.newDataInputStream())
} else {
println("Building on Travis......")
println("\nBuilding on Travis......")
properties.put("bintray.user",System.getenv("USER"))
properties.put("bintray.apikey",System.getenv("TOKEN"))
}
Expand Down
Expand Up @@ -176,7 +176,8 @@ public void run() {
removeAllViews();
for (int i = 0; i < tagsAdapter.getCount(); i++) {
TagCloudView.this.mTagCloud.add(new Tag(tagsAdapter.getPopularity(i)));
addView(tagsAdapter.getView(getContext(), i, TagCloudView.this));
View view = tagsAdapter.getView(getContext(), i, TagCloudView.this);
addView(view);
}

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

measureChildren(widthMode, heightMode);

if (layoutParams == null) {
layoutParams = (MarginLayoutParams) getLayoutParams();
}

int dimensionX = widthMode == MeasureSpec.EXACTLY ? contentWidth : minSize - layoutParams.leftMargin - layoutParams.rightMargin;
int dimensionY = heightMode == MeasureSpec.EXACTLY ? contentHeight : minSize - layoutParams.leftMargin - layoutParams.rightMargin;
setMeasuredDimension(dimensionX, dimensionY);

measureChildren(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
}

@Override
Expand Down

0 comments on commit cf147c3

Please sign in to comment.