Skip to content

Commit f96f4ea

Browse files
committed
fix: 修复布局编辑/创建对话框相关问题
1 parent fe69f6d commit f96f4ea

File tree

2 files changed

+111
-86
lines changed

2 files changed

+111
-86
lines changed

FCL/src/main/java/com/tungsten/fcl/ui/controller/ControllerInfoDialog.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.annotation.SuppressLint;
44
import android.content.Context;
55
import android.view.View;
6+
import android.view.Window;
7+
import android.widget.LinearLayout;
68
import android.widget.Toast;
79

810
import androidx.annotation.NonNull;
@@ -17,6 +19,7 @@
1719
import com.tungsten.fcllibrary.component.view.FCLEditText;
1820
import com.tungsten.fcllibrary.component.view.FCLLinearLayout;
1921
import com.tungsten.fcllibrary.component.view.FCLTextView;
22+
import com.tungsten.fcllibrary.util.ConvertUtils;
2023

2124
public class ControllerInfoDialog extends FCLDialog implements View.OnClickListener {
2225

@@ -40,6 +43,10 @@ public ControllerInfoDialog(@NonNull Context context, boolean create, Controller
4043
this.create = create;
4144
this.controller = controller;
4245
this.callback = callback;
46+
Window window = getWindow();
47+
if (window != null) {
48+
window.setLayout(ConvertUtils.dip2px(getContext(), 400), LinearLayout.LayoutParams.WRAP_CONTENT);
49+
}
4350
setContentView(R.layout.dialog_controller_info);
4451
setCancelable(false);
4552

@@ -63,9 +70,18 @@ public ControllerInfoDialog(@NonNull Context context, boolean create, Controller
6370
editDescription.setText(controller.getDescription());
6471

6572
FCLCheckBox moreInfo = findViewById(R.id.more_info);
66-
moreInfo.addCheckedChangeListener();
67-
68-
moreInfoLayout.visibilityProperty().bind(moreInfo.checkProperty());
73+
assert moreInfo != null;
74+
assert moreInfoLayout != null;
75+
moreInfoLayout.setVisibility(View.GONE);
76+
moreInfo.setOnCheckedChangeListener((buttonView, isChecked) -> {
77+
if (isChecked) {
78+
getWindow().setLayout(ConvertUtils.dip2px(getContext(), 400), LinearLayout.LayoutParams.MATCH_PARENT);
79+
moreInfoLayout.setVisibility(View.VISIBLE);
80+
} else {
81+
getWindow().setLayout(ConvertUtils.dip2px(getContext(), 400), ConvertUtils.dip2px(getContext(), 200));
82+
moreInfoLayout.setVisibility(View.GONE);
83+
}
84+
});
6985

7086
positive = findViewById(R.id.positive);
7187
negative = findViewById(R.id.negative);
Lines changed: 92 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,189 +1,198 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:layout_width="400dp"
4-
android:layout_height="match_parent"
53
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
66
android:padding="10dp">
77

88
<com.tungsten.fcllibrary.component.view.FCLTextView
99
android:id="@+id/title"
10-
android:singleLine="true"
1110
android:layout_width="wrap_content"
1211
android:layout_height="wrap_content"
13-
app:layout_constraintStart_toStartOf="parent"
12+
android:singleLine="true"
1413
app:layout_constraintEnd_toEndOf="parent"
15-
app:layout_constraintTop_toTopOf="parent"
16-
app:layout_constraintHorizontal_bias="0.5"/>
14+
app:layout_constraintHorizontal_bias="0.5"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent" />
1717

18-
<ScrollView
18+
<androidx.appcompat.widget.LinearLayoutCompat
19+
android:id="@+id/line"
1920
android:layout_width="match_parent"
2021
android:layout_height="wrap_content"
21-
android:layout_marginTop="10dp"
22-
android:layout_marginBottom="10dp"
23-
app:layout_constraintTop_toBottomOf="@+id/title"
24-
app:layout_constraintBottom_toTopOf="@+id/positive">
22+
android:orientation="horizontal"
23+
app:layout_constraintBottom_toTopOf="@id/more_info"
24+
app:layout_constraintTop_toBottomOf="@id/title">
2525

26-
<com.tungsten.fcllibrary.component.view.FCLLinearLayout
27-
android:layout_width="match_parent"
26+
<com.tungsten.fcllibrary.component.view.FCLTextView
27+
android:layout_width="0dp"
2828
android:layout_height="wrap_content"
29-
android:orientation="vertical">
29+
android:layout_gravity="center"
30+
android:layout_weight="1"
31+
android:singleLine="true"
32+
android:text="@string/control_info_name" />
33+
34+
<com.tungsten.fcllibrary.component.view.FCLEditText
35+
android:id="@+id/name"
36+
android:layout_width="250dp"
37+
android:layout_height="wrap_content"
38+
android:layout_gravity="center"
39+
android:hint="@string/input_hint_not_empty"
40+
android:singleLine="true"
41+
android:textSize="14sp" />
3042

31-
<androidx.appcompat.widget.LinearLayoutCompat
32-
android:layout_width="match_parent"
33-
android:layout_height="wrap_content"
34-
android:orientation="horizontal">
43+
</androidx.appcompat.widget.LinearLayoutCompat>
3544

36-
<com.tungsten.fcllibrary.component.view.FCLTextView
37-
android:layout_weight="1"
38-
android:singleLine="true"
39-
android:layout_width="0dp"
40-
android:layout_height="wrap_content"
41-
android:text="@string/control_info_name"
42-
android:layout_gravity="center"/>
43-
44-
<com.tungsten.fcllibrary.component.view.FCLEditText
45-
android:singleLine="true"
46-
android:textSize="14sp"
47-
android:hint="@string/input_hint_not_empty"
48-
android:id="@+id/name"
49-
android:layout_width="250dp"
50-
android:layout_height="wrap_content"
51-
android:layout_gravity="center"/>
45+
<com.tungsten.fcllibrary.component.view.FCLCheckBox
46+
android:id="@+id/more_info"
47+
android:layout_width="wrap_content"
48+
android:layout_height="wrap_content"
49+
android:text="@string/control_info_more"
50+
app:layout_constraintBottom_toTopOf="@id/scroll"
51+
app:layout_constraintStart_toStartOf="parent"
52+
app:layout_constraintTop_toBottomOf="@id/line" />
5253

53-
</androidx.appcompat.widget.LinearLayoutCompat>
54+
<ScrollView
55+
android:id="@+id/scroll"
56+
android:layout_width="match_parent"
57+
android:layout_height="0dp"
58+
android:layout_marginTop="5dp"
59+
android:layout_marginBottom="10dp"
60+
app:layout_constraintBottom_toTopOf="@+id/positive"
61+
app:layout_constraintTop_toBottomOf="@+id/more_info">
5462

55-
<com.tungsten.fcllibrary.component.view.FCLCheckBox
56-
android:layout_width="wrap_content"
57-
android:layout_height="wrap_content"
58-
android:text="@string/control_info_more"
59-
android:id="@+id/more_info"/>
63+
<LinearLayout
64+
android:layout_width="match_parent"
65+
android:layout_height="wrap_content"
66+
android:orientation="vertical">
6067

6168
<com.tungsten.fcllibrary.component.view.FCLLinearLayout
69+
android:id="@+id/more_info_layout"
6270
android:layout_width="match_parent"
6371
android:layout_height="wrap_content"
64-
android:orientation="vertical"
65-
android:id="@+id/more_info_layout">
72+
android:orientation="vertical">
6673

6774
<androidx.appcompat.widget.LinearLayoutCompat
6875
android:layout_width="match_parent"
6976
android:layout_height="wrap_content"
7077
android:orientation="horizontal">
7178

7279
<com.tungsten.fcllibrary.component.view.FCLTextView
73-
android:layout_weight="1"
74-
android:singleLine="true"
7580
android:layout_width="0dp"
7681
android:layout_height="wrap_content"
77-
android:text="@string/control_info_version"
78-
android:layout_gravity="center"/>
82+
android:layout_gravity="center"
83+
android:layout_weight="1"
84+
android:singleLine="true"
85+
android:text="@string/control_info_version" />
7986

8087
<com.tungsten.fcllibrary.component.view.FCLEditText
81-
android:singleLine="true"
82-
android:textSize="14sp"
83-
android:hint="@string/input_hint_optional"
8488
android:id="@+id/version"
8589
android:layout_width="250dp"
8690
android:layout_height="wrap_content"
87-
android:layout_gravity="center"/>
91+
android:layout_gravity="center"
92+
android:hint="@string/input_hint_optional"
93+
android:singleLine="true"
94+
android:textSize="14sp" />
8895

8996
</androidx.appcompat.widget.LinearLayoutCompat>
9097

9198
<androidx.appcompat.widget.LinearLayoutCompat
92-
android:layout_marginTop="5dp"
9399
android:layout_width="match_parent"
94100
android:layout_height="wrap_content"
101+
android:layout_marginTop="5dp"
95102
android:orientation="horizontal">
96103

97104
<com.tungsten.fcllibrary.component.view.FCLTextView
98-
android:layout_weight="1"
99-
android:singleLine="true"
100105
android:layout_width="0dp"
101106
android:layout_height="wrap_content"
102-
android:text="@string/control_info_version_code"
103-
android:layout_gravity="center"/>
107+
android:layout_gravity="center"
108+
android:layout_weight="1"
109+
android:singleLine="true"
110+
android:text="@string/control_info_version_code" />
104111

105112
<com.tungsten.fcllibrary.component.view.FCLEditText
106-
android:singleLine="true"
107-
android:textSize="14sp"
108-
android:inputType="number"
109-
android:hint="@string/input_hint_not_empty"
110113
android:id="@+id/version_code"
111114
android:layout_width="250dp"
112115
android:layout_height="wrap_content"
113-
android:layout_gravity="center"/>
116+
android:layout_gravity="center"
117+
android:hint="@string/input_hint_not_empty"
118+
android:inputType="number"
119+
android:singleLine="true"
120+
android:textSize="14sp" />
114121

115122
</androidx.appcompat.widget.LinearLayoutCompat>
116123

117124
<androidx.appcompat.widget.LinearLayoutCompat
118-
android:layout_marginTop="5dp"
119125
android:layout_width="match_parent"
120126
android:layout_height="wrap_content"
127+
android:layout_marginTop="5dp"
121128
android:orientation="horizontal">
122129

123130
<com.tungsten.fcllibrary.component.view.FCLTextView
124-
android:layout_weight="1"
125-
android:singleLine="true"
126131
android:layout_width="0dp"
127132
android:layout_height="wrap_content"
128-
android:text="@string/control_info_author"
129-
android:layout_gravity="center"/>
133+
android:layout_gravity="center"
134+
android:layout_weight="1"
135+
android:singleLine="true"
136+
android:text="@string/control_info_author" />
130137

131138
<com.tungsten.fcllibrary.component.view.FCLEditText
132-
android:singleLine="true"
133-
android:textSize="14sp"
134-
android:hint="@string/input_hint_optional"
135139
android:id="@+id/author"
136140
android:layout_width="250dp"
137141
android:layout_height="wrap_content"
138-
android:layout_gravity="center"/>
142+
android:layout_gravity="center"
143+
android:hint="@string/input_hint_optional"
144+
android:singleLine="true"
145+
android:textSize="14sp" />
139146

140147
</androidx.appcompat.widget.LinearLayoutCompat>
141148

142149
<androidx.appcompat.widget.LinearLayoutCompat
143-
android:layout_marginTop="5dp"
144150
android:layout_width="match_parent"
145151
android:layout_height="wrap_content"
152+
android:layout_marginTop="5dp"
146153
android:orientation="horizontal">
147154

148155
<com.tungsten.fcllibrary.component.view.FCLTextView
149-
android:layout_weight="1"
150-
android:singleLine="true"
151156
android:layout_width="0dp"
152157
android:layout_height="wrap_content"
153-
android:text="@string/control_info_description"
154-
android:layout_gravity="center"/>
158+
android:layout_gravity="top"
159+
android:layout_weight="1"
160+
android:singleLine="true"
161+
android:text="@string/control_info_description" />
155162

156163
<com.tungsten.fcllibrary.component.view.FCLEditText
157-
android:singleLine="true"
158-
android:textSize="14sp"
159-
android:hint="@string/input_hint_optional"
160164
android:id="@+id/description"
161165
android:layout_width="250dp"
162166
android:layout_height="wrap_content"
163-
android:layout_gravity="center"/>
167+
android:layout_gravity="top"
168+
android:gravity="start|top"
169+
android:hint="@string/input_hint_optional"
170+
android:textSize="14sp" />
164171

165172
</androidx.appcompat.widget.LinearLayoutCompat>
166173

167174
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
168175

169-
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
176+
</LinearLayout>
170177

171178
</ScrollView>
172179

173180
<com.tungsten.fcllibrary.component.view.FCLButton
174181
android:id="@+id/positive"
175-
android:text="@string/dialog_positive"
176182
android:layout_width="wrap_content"
177183
android:layout_height="wrap_content"
184+
android:text="@string/dialog_positive"
185+
app:layout_constraintBottom_toBottomOf="parent"
178186
app:layout_constraintStart_toStartOf="parent"
179-
app:layout_constraintBottom_toBottomOf="parent"/>
187+
app:layout_constraintTop_toBottomOf="@id/scroll" />
180188

181189
<com.tungsten.fcllibrary.component.view.FCLButton
182190
android:id="@+id/negative"
183-
android:text="@string/dialog_negative"
184191
android:layout_width="wrap_content"
185192
android:layout_height="wrap_content"
193+
android:text="@string/dialog_negative"
194+
app:layout_constraintBottom_toBottomOf="parent"
186195
app:layout_constraintEnd_toEndOf="parent"
187-
app:layout_constraintBottom_toBottomOf="parent"/>
196+
app:layout_constraintTop_toBottomOf="@id/scroll" />
188197

189198
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)