File tree Expand file tree Collapse file tree 3 files changed +32
-8
lines changed
java/app/rive/runtime/example Expand file tree Collapse file tree 3 files changed +32
-8
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import android.view.View
7
7
import android.view.ViewGroup
8
8
import androidx.fragment.app.Fragment
9
9
import app.rive.runtime.kotlin.RiveAnimationView
10
+ import app.rive.runtime.kotlin.core.Fit
10
11
import kotlin.properties.Delegates
11
12
12
13
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
@@ -41,6 +42,7 @@ class RiveFragment : Fragment() {
41
42
override fun onViewStateRestored (savedInstanceState : Bundle ? ) {
42
43
super .onViewStateRestored(savedInstanceState)
43
44
riveView.setRiveResource(rId)
45
+ riveView.fit = Fit .COVER
44
46
}
45
47
46
48
override fun onDestroy () {
Original file line number Diff line number Diff line change @@ -12,12 +12,21 @@ class RiveFragmentActivity : AppCompatActivity() {
12
12
super .onCreate(savedInstanceState)
13
13
setContentView(R .layout.activity_rive_fragment)
14
14
15
- // Instantiate a Rive fragment
16
- val bundle = bundleOf(RIVE_FRAGMENT_ARG_RES_ID to R .raw.basketball)
15
+ // Instantiate the basketball fragment
16
+ var bundle = bundleOf(RIVE_FRAGMENT_ARG_RES_ID to R .raw.basketball)
17
17
if (savedInstanceState == null ) {
18
18
supportFragmentManager.commit {
19
19
setReorderingAllowed(true )
20
- add<RiveFragment >(R .id.rive_fragment, args = bundle)
20
+ add<RiveFragment >(R .id.basketball_fragment, args = bundle)
21
+ }
22
+ }
23
+
24
+ // Instantiate the flux fragment
25
+ bundle = bundleOf(RIVE_FRAGMENT_ARG_RES_ID to R .raw.flux_capacitor)
26
+ if (savedInstanceState == null ) {
27
+ supportFragmentManager.commit {
28
+ setReorderingAllowed(true )
29
+ add<RiveFragment >(R .id.flux_fragment, args = bundle)
21
30
}
22
31
}
23
32
}
Original file line number Diff line number Diff line change 6
6
android : layout_height =" match_parent"
7
7
tools : context =" .MainActivity" >
8
8
9
-
10
- <androidx .fragment.app.FragmentContainerView
11
- xmlns : android =" http://schemas.android.com/apk/res/android"
12
- android : id =" @+id/rive_fragment"
9
+ <ScrollView
13
10
android : layout_width =" match_parent"
14
- android : layout_height =" match_parent" />
11
+ android : layout_height =" match_parent" >
12
+
13
+ <LinearLayout
14
+ android : layout_width =" match_parent"
15
+ android : layout_height =" wrap_content"
16
+ android : orientation =" vertical" >
17
+
18
+ <androidx .fragment.app.FragmentContainerView
19
+ android : id =" @+id/basketball_fragment"
20
+ android : layout_width =" match_parent"
21
+ android : layout_height =" match_parent" />
15
22
23
+ <androidx .fragment.app.FragmentContainerView
24
+ android : id =" @+id/flux_fragment"
25
+ android : layout_width =" match_parent"
26
+ android : layout_height =" match_parent" />
16
27
28
+ </LinearLayout >
29
+ </ScrollView >
17
30
18
31
</androidx .constraintlayout.widget.ConstraintLayout>
You can’t perform that action at this time.
0 commit comments