Created
July 18, 2019 09:48
-
-
Save StelianMorariu/322898b7eaecd5c4a02d36acc3585b86 to your computer and use it in GitHub Desktop.
Apply window insets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// override the default transitions because we create the circular reveal manually | |
overridePendingTransition(R.anim.anim_no_translate, R.anim.anim_no_translate) | |
setContentView(R.layout.activity_home) | |
val rootLayout: FrameLayout = findViewById(R.id.rootLayout) | |
rootLayout.systemUiVisibility = | |
SYSTEM_UI_FLAG_LAYOUT_STABLE or SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | |
} | |
companion object { | |
fun newIntent(context: Context): Intent { | |
return Intent(context, HomeActivity::class.java) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MetricsProfileFragment : Fragment() { | |
@Inject | |
lateinit var viewModelFactory: ViewModelProvider.Factory | |
lateinit var metricsViewModel: MetricsProfileViewModel | |
private lateinit var menuBtn: ImageView | |
private lateinit var loadingImageView: ImageView | |
private lateinit var titleTv: TextView | |
private lateinit var motionLayout: MotionLayout | |
private lateinit var recyclerView: RecyclerView | |
private lateinit var adapter: MetricsItemAdapter | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View? { | |
val view = inflater.inflate(R.layout.fragment_metrics_profile, container, false) | |
// initialisation code ommitted | |
return view | |
} | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
view.requestApplyInsets() | |
view.setOnApplyWindowInsetsListener { view, windowInsets -> | |
var marginParams = view.layoutParams as ViewGroup.MarginLayoutParams | |
marginParams.topMargin = windowInsets.systemWindowInsetTop | |
// marginParams.bottomMargin = windowInsets.systemWindowInsetBottom | |
windowInsets | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment