Skip to content

Commit

Permalink
Create FragmentHost
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYanCoding committed Aug 25, 2018
1 parent ec4c95a commit 5b1fa2c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</intent-filter>
</activity>
<activity android:name=".CustomAdaptActivity"/>
<activity android:name=".FragmentHost"/>

<!-- 如果您项目中的所有页面都只需要以高或宽中的一个作为基准进行适配的话, 那就只需要填写高或宽中的一个设计图尺寸即可 -->
<meta-data
Expand Down
50 changes: 50 additions & 0 deletions demo/src/main/java/me/jessyan/autosize/demo/FragmentHost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2018 JessYan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.jessyan.autosize.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import me.jessyan.autosize.internal.CustomAdapt;

/**
* ================================================
* Created by JessYan on 2018/8/25 14:39
* <a href="mailto:[email protected]">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* ================================================
*/
public class FragmentHost extends AppCompatActivity implements CustomAdapt{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_host);
getSupportFragmentManager().beginTransaction().add(R.id.container1, new CustomFragment1()).commit();
getSupportFragmentManager().beginTransaction().add(R.id.container2, new CustomFragment2()).commit();
getSupportFragmentManager().beginTransaction().add(R.id.container3, new CustomFragment3()).commit();
}

@Override
public boolean isBaseOnWidth() {
return true;
}

@Override
public float getSizeInDp() {
return 720;
}
}
24 changes: 24 additions & 0 deletions demo/src/main/res/layout/activity_host.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/container1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>

<FrameLayout
android:id="@+id/container2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>

<FrameLayout
android:id="@+id/container3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>

0 comments on commit 5b1fa2c

Please sign in to comment.