Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds-android
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
云深项目组
beyond-clouds-android
Commits
4de1f4cf
Commit
4de1f4cf
authored
Mar 17, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DynamicGridLayout更新-计算padding
parent
e86dea51
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
app/src/main/java/cn/yunliyunwai/beyondclouds/view/DynamicGridLayout.java
+7
-5
app/src/main/res/layout/post_item.xml
+3
-2
No files found.
app/src/main/java/cn/yunliyunwai/beyondclouds/view/DynamicGridLayout.java
View file @
4de1f4cf
...
...
@@ -99,7 +99,9 @@ public class DynamicGridLayout extends ViewGroup {
}
// 计算布局尺寸
int
maxWidth
=
MeasureSpec
.
getSize
(
getMeasuredWidth
());
int
measuredWidth
=
MeasureSpec
.
getSize
(
getMeasuredWidth
());
int
maxWidth
=
measuredWidth
-
(
getPaddingLeft
()
+
getPaddingRight
());
// 每个图片的尺寸
int
imageSize
=
(
maxWidth
-
(
mCol
-
1
)
*
mSpacing
)
/
mCol
;
...
...
@@ -108,7 +110,7 @@ public class DynamicGridLayout extends ViewGroup {
imageSize
=
(
int
)
(
imageSize
*
0.66
);
}
int
layoutHeight
=
imageSize
*
mRow
+
(
mRow
-
1
)
*
mSpacing
;
int
layoutHeight
=
imageSize
*
mRow
+
(
mRow
-
1
)
*
mSpacing
+
getPaddingTop
()
+
getPaddingBottom
()
;
LayoutParams
layoutParams
=
getLayoutParams
();
layoutParams
.
height
=
layoutHeight
;
...
...
@@ -121,8 +123,8 @@ public class DynamicGridLayout extends ViewGroup {
currentCol
=
i
-
(
currentRow
*
mCol
);
ImageView
imageView
=
createImageView
(
mImgUrls
.
get
(
i
));
this
.
addView
(
imageView
,
new
LayoutParams
(
imageSize
,
imageSize
));
int
left
=
computePosition
(
currentCol
,
imageSize
);
int
top
=
computePosition
(
currentRow
,
imageSize
);
int
left
=
computePosition
(
currentCol
,
imageSize
)
+
getPaddingLeft
()
;
int
top
=
computePosition
(
currentRow
,
imageSize
)
+
getPaddingTop
()
;
imageView
.
layout
(
left
,
top
,
left
+
imageSize
,
top
+
imageSize
);
}
isImageInit
=
true
;
...
...
@@ -157,7 +159,7 @@ public class DynamicGridLayout extends ViewGroup {
}
if
(
imageHeight
!=
-
1
&&
imageHeight
!=
layoutParams
.
height
)
{
layoutParams
.
height
=
imageHeight
;
layoutParams
.
height
=
imageHeight
+
getPaddingTop
()
+
getPaddingBottom
()
;
setLayoutParams
(
layoutParams
);
}
...
...
app/src/main/res/layout/post_item.xml
View file @
4de1f4cf
...
...
@@ -58,6 +58,7 @@
<TextView
android:id=
"@+id/txt_content"
android:layout_marginTop=
"10dp"
android:paddingBottom=
"14dp"
android:text=
"SpringBoot迭代发布JRA瘦身配置"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -83,7 +84,7 @@
<cn.yunliyunwai.beyondclouds.view.DynamicGridLayout
android:id=
"@+id/dynamic_grid_layout"
android:
layout_marginTop=
"14
dp"
android:
paddingBottom=
"8
dp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/barrier_content"
...
...
@@ -97,7 +98,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<View
android:layout_marginTop=
"
18
dp"
android:layout_marginTop=
"
4
dp"
app:layout_constraintTop_toBottomOf=
"@id/barrier_dynamic_grid"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment