Skip to content

Commit 5047650

Browse files
committed
margin无效排查
1 parent 3fdac7e commit 5047650

4 files changed

Lines changed: 39 additions & 19 deletions

File tree

app/src/main/java/com/example/lvruheng/autoflowlayout/AutoFlowLayout.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ public class AutoFlowLayout <T> extends ViewGroup {
5757
* 多选标志,默认支持单选
5858
*/
5959
private boolean mIsMultiChecked;
60-
/**
61-
* 设置View的选中/未选中背景色或者单纯的背景色
62-
*/
63-
private Drawable mViewBgDrawable;
6460
/**
6561
* 记录选中的View
6662
*/
@@ -605,9 +601,6 @@ public void setAllViews(List<View> views) {
605601
}
606602
for (int i = 0; i < views.size(); i++) {
607603
View view = views.get(i);
608-
if (mViewBgDrawable != null) {
609-
view.setBackgroundDrawable(mViewBgDrawable);
610-
}
611604
addView(view);
612605
}
613606
requestLayout();
@@ -729,13 +722,6 @@ public boolean isMultiChecked() {
729722
public void setMultiChecked(boolean isMultiChecked) {
730723
mIsMultiChecked = isMultiChecked;
731724
}
732-
/**
733-
* 设置选择背景
734-
* @param drawable selector 设置选中与未选中的背景或者单纯的背景色
735-
*/
736-
public void setCheckedBackgorud(Drawable drawable) {
737-
mViewBgDrawable = drawable;
738-
}
739725

740726
/**
741727
* 获得选中的View集合
@@ -811,6 +797,7 @@ public float getVerticalSpace() {
811797
*/
812798
public void setColumnNumbers(int columnNumbers) {
813799
mColumnNumbers = columnNumbers;
800+
requestLayout();
814801
}
815802

816803
/**
@@ -827,6 +814,7 @@ public int getColumnNumbers() {
827814
*/
828815
public void setRowNumbers(int rowNumbers) {
829816
mRowNumbers = rowNumbers;
817+
requestLayout();
830818
}
831819

832820
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="100dp"
4+
android:layout_height="100dp"
5+
android:paddingBottom="12dp"
6+
android:paddingTop="12dp"
7+
android:paddingLeft="8dp"
8+
android:gravity="center"
9+
android:paddingRight="8dp"
10+
android:orientation="vertical">
11+
<TextView
12+
android:gravity="center"
13+
android:drawableLeft="@mipmap/ic_launcher"
14+
android:id="@+id/tv_attr_tag"
15+
android:layout_width="match_parent"
16+
android:layout_height="match_parent"
17+
android:paddingBottom="6dp"
18+
android:paddingTop="6dp"
19+
android:paddingLeft="10dp"
20+
android:paddingRight="10dp"
21+
android:textSize="16sp"
22+
android:textColor="@color/btn_common_text"
23+
android:background="@drawable/bg_sub_tag">
24+
25+
</TextView>
26+
</FrameLayout>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
7+
</LinearLayout>

app/src/main/res/layout/special_item.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="wrap_content"
44
android:layout_height="wrap_content"
5-
android:layout_marginTop="12dp"
6-
android:layout_marginBottom="12dp"
7-
android:layout_marginLeft="8dp"
5+
android:paddingTop="12dp"
6+
android:paddingBottom="12dp"
7+
android:paddingLeft="8dp"
88
android:gravity="center"
9-
android:layout_marginRight="8dp"
9+
android:paddingRight="8dp"
1010
android:orientation="vertical">
1111
<TextView
12-
android:text="你好"
1312
android:id="@+id/tv_attr_tag"
1413
android:layout_width="wrap_content"
1514
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)