Skip to content

Commit 3db932c

Browse files
fragment优化
1 parent 7eed14f commit 3db932c

File tree

13 files changed

+213
-68
lines changed

13 files changed

+213
-68
lines changed

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/aranandroid/customview/ui/SquareMoreActivity.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
package com.aranandroid.customview.ui
22

33
import android.annotation.SuppressLint
4-
import android.app.Activity
54
import android.os.Bundle
6-
import android.os.PersistableBundle
75
import android.util.Log
8-
import android.widget.RadioButton
96
import android.widget.Toast
10-
import androidx.appcompat.app.AppCompatActivity
117
import androidx.fragment.app.FragmentActivity
128
import com.aranandroid.customview.R
13-
import com.aranandroid.customview.squareview.SquareTextView
14-
import com.aranandroid.customview.ui.square.AFragment
15-
import com.aranandroid.customview.ui.square.BFragment
9+
import com.aranandroid.customview.ui.square.*
1610
import kotlinx.android.synthetic.main.activity_square_moreview.*
17-
import kotlinx.android.synthetic.main.activity_square_textview.*
18-
import kotlinx.android.synthetic.main.item_main.*
19-
import kotlinx.coroutines.GlobalScope
20-
import kotlinx.coroutines.delay
21-
import kotlinx.coroutines.launch
22-
import kotlinx.coroutines.runBlocking
2311

2412
class SquareMoreActivity : FragmentActivity() {
2513
@SuppressLint("WrongViewCast")
@@ -30,10 +18,13 @@ class SquareMoreActivity : FragmentActivity() {
3018
square_text_image.imageView.setOnClickListener{v ->
3119
Toast.makeText(this ,"click",Toast.LENGTH_SHORT).show()
3220
}
33-
fragment_top.fragments = linkedMapOf(Pair(R.id.f, AFragment()),Pair(R.id.h, BFragment()))
34-
fragment_top.changeItme={group, checkedId ->
21+
fragment_bottom.fragments = linkedMapOf(Pair(R.id.a, AFragment()),Pair(R.id.b, BFragment()),Pair(R.id.c, CFragment()),Pair(R.id.d, DFragment()))
22+
fragment_bottom.changeItme={group, checkedId ->
3523
Log.e("TAG", "onCreate: "+checkedId )
3624
}
25+
26+
fragment_top.fragments = linkedMapOf(Pair(R.id.f, FFragment()),Pair(R.id.h, HFragment()))
27+
3728
}
3829

3930

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.aranandroid.customview.ui.square
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.aranandroid.customview.R
9+
10+
class CFragment() : Fragment(R.layout.fragment_c) {
11+
12+
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.aranandroid.customview.ui.square
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.aranandroid.customview.R
9+
10+
class DFragment() : Fragment(R.layout.fragment_d) {
11+
12+
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.aranandroid.customview.ui.square
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.aranandroid.customview.R
9+
10+
class FFragment() : Fragment(R.layout.fragment_f) {
11+
12+
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.aranandroid.customview.ui.square
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.aranandroid.customview.R
9+
10+
class HFragment() : Fragment(R.layout.fragment_h) {
11+
12+
13+
}

app/src/main/res/layout/activity_square_moreview.xml

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,44 +94,98 @@
9494
>
9595
</com.aranandroid.customview.squareview.SquareTextImage>
9696

97-
<com.aranandroid.customview.fragment.FragmentBottom
97+
98+
<com.aranandroid.customview.fragment.FragmentTop
9899
android:id="@+id/fragment_top"
99100
android:layout_width="match_parent"
100101
android:layout_height="500dp">
101-
<com.aranandroid.customview.squareview.SquareLinearLayout
102-
android:layout_height="@dimen/dp_40"
103-
app:corner="5dp"
104-
android:layout_marginLeft="@dimen/dp_10"
105-
android:layout_marginRight="@dimen/dp_10"
106-
android:padding="3dp"
107-
app:background_color="@color/red"
108-
android:layout_width="match_parent">
109-
<com.aranandroid.customview.squareview.SquareRadioButton
102+
<com.aranandroid.customview.squareview.SquareRadioButton
103+
android:layout_margin="2dp"
104+
android:id="@+id/f"
105+
android:layout_height="30dp"
106+
android:layout_width="0dp"
107+
android:layout_weight="1"
108+
app:selected_corner="5dp"
109+
android:checked="true"
110+
app:selected_background_color="@color/colorAccent"
111+
android:gravity="center"
112+
android:text="F"
113+
tools:ignore="MissingConstraints" />
114+
115+
<com.aranandroid.customview.squareview.SquareRadioButton
116+
android:layout_margin="2dp"
117+
android:id="@+id/h"
118+
android:layout_height="30dp"
119+
android:layout_width="0dp"
120+
android:layout_weight="1"
121+
app:selected_corner="5dp"
122+
app:selected_background_color="@color/colorAccent"
123+
android:gravity="center"
124+
android:text="H"
125+
tools:ignore="MissingConstraints" />
126+
</com.aranandroid.customview.fragment.FragmentTop>
127+
128+
129+
<TextView
130+
android:layout_width="match_parent"
131+
android:layout_height="match_parent"
132+
android:text="ddd"
133+
></TextView>
134+
<com.aranandroid.customview.fragment.FragmentBottom
135+
android:id="@+id/fragment_bottom"
136+
android:layout_width="match_parent"
137+
android:layout_marginTop="150dp"
138+
android:layout_height="500dp">
139+
<!-- <com.aranandroid.customview.squareview.SquareLinearLayout-->
140+
<!-- android:layout_height="@dimen/dp_40"-->
141+
<!-- app:corner="5dp"-->
142+
<!-- android:layout_marginLeft="@dimen/dp_10"-->
143+
<!-- android:layout_marginRight="@dimen/dp_10"-->
144+
<!-- android:padding="3dp"-->
145+
<!-- app:background_color="@color/red"-->
146+
<!-- android:layout_width="match_parent">-->
147+
<RadioButton
110148
android:layout_margin="2dp"
111-
android:id="@+id/f"
149+
android:id="@+id/a"
112150
android:layout_height="30dp"
113151
android:layout_width="0dp"
114152
android:layout_weight="1"
115-
app:selected_corner="5dp"
116153
android:checked="true"
117-
app:selected_background_color="@color/colorAccent"
118154
android:gravity="center"
119-
android:text="F"
155+
android:text="A"
120156
tools:ignore="MissingConstraints" />
121157

122-
<com.aranandroid.customview.squareview.SquareRadioButton
158+
<RadioButton
123159
android:layout_margin="2dp"
124-
android:id="@+id/h"
160+
android:id="@+id/b"
125161
android:layout_height="30dp"
126162
android:layout_width="0dp"
127163
android:layout_weight="1"
128-
app:selected_corner="5dp"
129-
app:selected_background_color="@color/colorAccent"
130164
android:gravity="center"
131-
android:text="H"
165+
android:text="B"
132166
tools:ignore="MissingConstraints" />
133-
</com.aranandroid.customview.squareview.SquareLinearLayout>
167+
<RadioButton
168+
android:layout_margin="2dp"
169+
android:id="@+id/c"
170+
android:layout_height="30dp"
171+
android:layout_width="0dp"
172+
android:layout_weight="1"
173+
android:gravity="center"
174+
android:text="C"
175+
tools:ignore="MissingConstraints" />
176+
<RadioButton
177+
android:layout_margin="2dp"
178+
android:id="@+id/d"
179+
android:layout_height="30dp"
180+
android:layout_width="0dp"
181+
android:layout_weight="1"
182+
android:gravity="center"
183+
android:text="D"
184+
tools:ignore="MissingConstraints" />
185+
<!-- </com.aranandroid.customview.squareview.SquareLinearLayout>-->
134186
</com.aranandroid.customview.fragment.FragmentBottom>
187+
188+
135189
</LinearLayout>
136190
</ScrollView>
137191
</com.aranandroid.customview.title.TitleLayout>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:ignore="MissingDefaultResource">
8+
9+
<TextView
10+
android:layout_width="match_parent"
11+
android:layout_height="match_parent"
12+
android:gravity="center"
13+
android:textSize="62sp"
14+
android:text="C" />
15+
16+
</LinearLayout>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:ignore="MissingDefaultResource">
8+
9+
<TextView
10+
android:layout_width="match_parent"
11+
android:layout_height="match_parent"
12+
android:gravity="center"
13+
android:textSize="62sp"
14+
android:text="D" />
15+
16+
</LinearLayout>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:ignore="MissingDefaultResource">
8+
9+
<TextView
10+
android:layout_width="match_parent"
11+
android:layout_height="match_parent"
12+
android:gravity="center"
13+
android:textSize="62sp"
14+
android:text="F" />
15+
16+
</LinearLayout>

0 commit comments

Comments
 (0)