Skip to content

Commit 5b1fa2c

Browse files
committed
Create FragmentHost
1 parent ec4c95a commit 5b1fa2c

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

demo/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</intent-filter>
1818
</activity>
1919
<activity android:name=".CustomAdaptActivity"/>
20+
<activity android:name=".FragmentHost"/>
2021

2122
<!-- 如果您项目中的所有页面都只需要以高或宽中的一个作为基准进行适配的话, 那就只需要填写高或宽中的一个设计图尺寸即可 -->
2223
<meta-data
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2018 JessYan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package me.jessyan.autosize.demo;
17+
18+
import android.os.Bundle;
19+
import android.support.annotation.Nullable;
20+
import android.support.v7.app.AppCompatActivity;
21+
22+
import me.jessyan.autosize.internal.CustomAdapt;
23+
24+
/**
25+
* ================================================
26+
* Created by JessYan on 2018/8/25 14:39
27+
* <a href="mailto:[email protected]">Contact me</a>
28+
* <a href="https://github.com/JessYanCoding">Follow me</a>
29+
* ================================================
30+
*/
31+
public class FragmentHost extends AppCompatActivity implements CustomAdapt{
32+
@Override
33+
protected void onCreate(@Nullable Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.activity_host);
36+
getSupportFragmentManager().beginTransaction().add(R.id.container1, new CustomFragment1()).commit();
37+
getSupportFragmentManager().beginTransaction().add(R.id.container2, new CustomFragment2()).commit();
38+
getSupportFragmentManager().beginTransaction().add(R.id.container3, new CustomFragment3()).commit();
39+
}
40+
41+
@Override
42+
public boolean isBaseOnWidth() {
43+
return true;
44+
}
45+
46+
@Override
47+
public float getSizeInDp() {
48+
return 720;
49+
}
50+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical">
6+
7+
<FrameLayout
8+
android:id="@+id/container1"
9+
android:layout_width="match_parent"
10+
android:layout_height="0dp"
11+
android:layout_weight="1"/>
12+
13+
<FrameLayout
14+
android:id="@+id/container2"
15+
android:layout_width="match_parent"
16+
android:layout_height="0dp"
17+
android:layout_weight="1"/>
18+
19+
<FrameLayout
20+
android:id="@+id/container3"
21+
android:layout_width="match_parent"
22+
android:layout_height="0dp"
23+
android:layout_weight="1"/>
24+
</LinearLayout>

0 commit comments

Comments
 (0)