Skip to content

Commit ec4c95a

Browse files
committed
Improve CustomAdaptActivity
1 parent 8ae4644 commit ec4c95a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

demo/src/main/java/me/jessyan/autosize/demo/CustomAdaptActivity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
package me.jessyan.autosize.demo;
1717

1818
import android.app.Activity;
19+
import android.content.Intent;
1920
import android.os.Bundle;
21+
import android.support.v4.app.Fragment;
2022
import android.support.v7.app.AppCompatActivity;
23+
import android.view.View;
2124

2225
import me.jessyan.autosize.internal.CustomAdapt;
2326

@@ -43,6 +46,14 @@ protected void onCreate(Bundle savedInstanceState) {
4346
setContentView(R.layout.activity_custom_adapt);
4447
}
4548

49+
/**
50+
* 跳转到 {@link FragmentHost}, 展示项目内部的 {@link Fragment} 自定义适配参数的用法
51+
*
52+
* @param view {@link View}
53+
*/
54+
public void goCustomAdaptFragment(View view) {
55+
startActivity(new Intent(getApplicationContext(), FragmentHost.class));
56+
}
4657
/**
4758
* 是否按照宽度进行等比例适配 (为了保证在高宽比不同的屏幕上也能正常适配, 所以只能在宽度和高度之中选一个作为基准进行适配)
4859
*

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
android:background="#fff"
3131
/>
3232

33-
<TextView
33+
<Button
3434
android:layout_width="match_parent"
3535
android:layout_height="100dp"
3636
android:background="#0f3"
37-
android:gravity="center"
38-
android:text="H-100dp"
39-
android:textColor="#fff"
37+
android:onClick="goCustomAdaptFragment"
38+
android:text="CustomAdapt(Fragment)"
39+
android:textColor="#00f"
4040
android:textSize="20sp"
4141
/>
4242

0 commit comments

Comments
 (0)