Skip to content

Commit 8535ec5

Browse files
committed
Demo used AndroidAutoSize
1 parent 3977bed commit 8535ec5

File tree

5 files changed

+32
-16
lines changed

5 files changed

+32
-16
lines changed

demo/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ dependencies {
7777
//Art 核心库不再包含 AndroidAutoLayout, 现在可自行选择屏幕适配方案, 不想使用 AndroidAutoLayout 就不要依赖 art-autolayout
7878
// implementation 'me.jessyan:art-autolayout:2.5.0'
7979

80+
//现在已经将 Demo 中的屏幕适配框架从 AndroidAutoLayout 替换为 AndroidAutoSize, AndroidAutoLayout 和 AndroidAutoSize 可以在项目中共存
81+
//所以旧项目只要依赖 art-autolayout 即可兼容之前的旧页面, 新页面可以使用 AndroidAutoSize 进行适配, 等有时间了再将旧页面全部替换为 AndroidAutoSize
82+
implementation rootProject.ext.dependencies["autosize"]
83+
8084
//Art 核心库不再包含 Glide, 想使用其他图片加载框架或者想自行扩展 ImageLoaderStrategy 就不要依赖 art-imageloader-glide
8185
//依赖 art-imageloader-glide 后还需要在 GlobalConfiguration 中手动注册 GlideImageLoaderStrategy
8286
implementation 'me.jessyan:art-imageloader-glide:2.5.0'

demo/src/main/AndroidManifest.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
</intent-filter>
2727
</activity>
2828

29-
<!-- art配置 -->
29+
<!-- 只要依赖 AutoSize 就必须填写设计图尺寸, 否则报错, 不想使用 AutoSize 就不要依赖 AutoSize
30+
只要填写完设计图的尺寸, AutoSize 就会自动启动, 以下 dp 尺寸是根据公式 px / (dpi / 160) 求出, 运算时使用测试机的 dpi 即可
31+
AutoSize 的详细介绍请看这里 https://juejin.im/post/5bce688e6fb9a05cf715d1c2
32+
-->
33+
<meta-data
34+
android:name="design_width_in_dp"
35+
android:value="360"/>
36+
<meta-data
37+
android:name="design_height_in_dp"
38+
android:value="640"/>
39+
40+
<!-- Art 配置 -->
3041
<meta-data
3142
android:name="me.jessyan.mvpart.demo.app.GlobalConfiguration"
3243
android:value="ConfigModule"/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
android:id="@+id/swipeRefreshLayout"
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:paddingLeft="15px"
17-
android:paddingTop="15px"
16+
android:paddingLeft="4dp"
17+
android:paddingTop="4dp"
1818
>
1919

2020
<android.support.v7.widget.RecyclerView

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xmlns:tools="http://schemas.android.com/tools"
66
android:id="@+id/toolbar"
77
android:layout_width="match_parent"
8-
android:layout_height="120px"
8+
android:layout_height="50dp"
99
android:background="?attr/colorPrimary"
1010
app:contentInsetStart="0dp"
1111
>
@@ -21,8 +21,8 @@
2121
android:layout_width="wrap_content"
2222
android:layout_height="wrap_content"
2323
android:layout_centerVertical="true"
24-
android:layout_marginLeft="30px"
25-
android:layout_marginRight="30px"
24+
android:layout_marginLeft="10dp"
25+
android:layout_marginRight="10dp"
2626
android:src="@mipmap/ic_arrow_back_white_24dp"/>
2727
</RelativeLayout>
2828

@@ -32,6 +32,7 @@
3232
android:layout_height="wrap_content"
3333
android:layout_gravity="center"
3434
android:textColor="@color/white"
35-
android:textSize="18dp"
35+
android:textSize="18sp"
3636
tools:text="@string/app_name"/>
37+
3738
</android.support.v7.widget.Toolbar>
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
android:layout_width="match_parent"
5-
android:layout_height="550px"
6-
android:layout_marginRight="15px"
7-
android:layout_marginBottom="15px"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="174dp"
6+
android:layout_marginRight="4dp"
7+
android:layout_marginBottom="4dp"
88
>
99

1010
<ImageView
1111
android:id="@+id/iv_avatar"
1212
android:layout_width="match_parent"
1313
android:layout_height="match_parent"
1414
android:scaleType="centerCrop"
15-
tools:src="#000000" />
15+
tools:src="#000000"/>
1616

1717

1818
<TextView
1919
android:id="@+id/tv_name"
2020
android:layout_width="wrap_content"
2121
android:layout_height="wrap_content"
2222
android:layout_gravity="center_horizontal|bottom"
23-
android:layout_marginBottom="10px"
23+
android:layout_marginBottom="3dp"
2424
android:textColor="@color/white"
25-
android:textSize="40px"
26-
tools:text="ss" />
25+
android:textSize="18sp"
26+
tools:text="ss"/>
2727

2828
</android.support.v7.widget.CardView>

0 commit comments

Comments
 (0)