Skip to content

Commit 10dfc61

Browse files
committed
更新2
1 parent 523ec4b commit 10dfc61

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

CustomControlLibs/src/main/java/com/example/customcontrollibs/viewground/ShowComment.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,26 @@ private void initView() {
4848
private void initAttribteSet(AttributeSet attrs) {
4949
TypedArray array = mContext.obtainStyledAttributes(attrs, R.styleable.ShowComment);
5050
isNetWorkUrl(array.getBoolean(R.styleable.ShowComment_isNetWorkUrl, true));
51+
displayPicture(array.getBoolean(R.styleable.ShowComment_displayPicture,true));
5152
array.recycle();
5253
}
5354

5455
public void setImageSize(int value) {
55-
int dp = DensityUtil.px2dip(mContext, value);
56+
int dp = DensityUtil.dip2px(mContext, value);
5657
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) message.getLayoutParams();
5758
linearParams.width = dp;
5859
linearParams.height = dp;
5960
message.setLayoutParams(linearParams);
6061
}
6162

63+
public void displayPicture(boolean judge) {
64+
if (judge) {
65+
message.setVisibility(VISIBLE);
66+
} else {
67+
message.setVisibility(GONE);
68+
}
69+
}
70+
6271
public void isNetWorkUrl(boolean judge) {
6372
this.judge = judge;
6473
}

CustomControlLibs/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@
101101

102102
<declare-styleable name="ShowComment">
103103
<attr name="isNetWorkUrl" format="boolean"/>
104+
<attr name="displayPicture" format="boolean"/>
104105
</declare-styleable>
105106
</resources>

0 commit comments

Comments
 (0)