Skip to content

Commit 7d018f4

Browse files
committed
Improve activity_custom_adapt.xml
1 parent 6cb694b commit 7d018f4

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

demo/src/main/res/layout/activity_custom_adapt.xml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,30 @@
88
tools:context=".CustomAdaptActivity">
99

1010
<LinearLayout
11-
android:layout_width="wrap_content"
11+
android:layout_width="match_parent"
1212
android:layout_height="wrap_content"
1313
android:orientation="vertical">
1414

1515
<TextView
16-
android:layout_width="100dp"
17-
android:layout_height="250dp"
16+
android:layout_width="match_parent"
17+
android:layout_height="248dp"
1818
android:background="@color/colorPrimary"
1919
android:gravity="center"
20-
android:text="H-250dp"
20+
android:text="H-248dp\n(Height Total:667dp)"
2121
android:textColor="#fff"
2222
android:textSize="20sp"/>
2323

24+
<!--把高度设置为 2 dp 的原因是想展示 AndroidAutoSize 可以把适配精度精确到 1 dp (写 2 dp 是为了更显眼, 写 1 dp 也是可以的)
25+
如果您看得到屏幕中间高度为 2 dp 的白色间隙, 说明本适配方案, 能精确适配, 您可以放心填写 dp 值-->
26+
27+
<TextView
28+
android:layout_width="match_parent"
29+
android:layout_height="2dp"
30+
android:background="#fff"
31+
/>
32+
2433
<TextView
25-
android:layout_width="100dp"
34+
android:layout_width="match_parent"
2635
android:layout_height="100dp"
2736
android:background="#0f3"
2837
android:gravity="center"
@@ -32,7 +41,7 @@
3241
/>
3342

3443
<TextView
35-
android:layout_width="100dp"
44+
android:layout_width="match_parent"
3645
android:layout_height="125dp"
3746
android:background="#d0f"
3847
android:gravity="center"
@@ -41,25 +50,12 @@
4150
android:textSize="20sp"/>
4251

4352
<TextView
44-
android:layout_width="100dp"
53+
android:layout_width="match_parent"
4554
android:layout_height="192dp"
4655
android:background="#d21"
4756
android:gravity="center"
4857
android:text="H-192dp"
4958
android:textColor="#fff"
5059
android:textSize="20sp"/>
5160
</LinearLayout>
52-
53-
<!--把高度设置为 666 dp 的原因是想展示 AndroidAutoSize 可以把适配精度精确到 1 dp (667dp - 666dp = 1dp)
54-
如果您看得到屏幕下方高度为 1 dp 的白色间隙, 说明本适配方案, 能精确适配, 您可以放心填写 dp 值-->
55-
<TextView
56-
android:layout_width="match_parent"
57-
android:layout_height="666dp"
58-
android:background="#0ff"
59-
android:gravity="center"
60-
android:text="H-666dp\n(total:667dp)"
61-
android:textColor="#fff"
62-
android:textSize="30sp"/>
63-
64-
6561
</LinearLayout>

0 commit comments

Comments
 (0)