Created
August 7, 2019 13:08
-
-
Save DVegasa/331ee7fef8a867c651886bed4f79d407 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <FrameLayout | |
| android:id="@+id/root" | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context=".MainActivity"> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context=".MainActivity" | |
| android:orientation="vertical" | |
| android:id="@+id/content"> | |
| <TextView | |
| android:text="Давайте познакомимся" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:id="@+id/textView" | |
| android:layout_marginStart="8dp" | |
| android:layout_marginTop="8dp" | |
| android:textSize="24sp" | |
| android:textColor="#FF000000"/> | |
| <Button | |
| android:text="1. Показать простой диалог" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:id="@+id/btn_1" | |
| android:layout_marginStart="8dp" | |
| android:layout_marginTop="8dp"/> | |
| <Button | |
| android:text="2. Показать простой диалог со списком" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:id="@+id/btn_2" | |
| android:layout_marginStart="8dp" | |
| android:layout_marginTop="8dp"/> | |
| <Button | |
| android:text="3. Показать диалог с кастомным макетом" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:id="@+id/btn_3" | |
| android:layout_marginStart="8dp" | |
| android:layout_marginTop="8dp"/> | |
| <Button | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="4. Полноэкранный кастомный диалог" | |
| android:id="@+id/btn_4" | |
| android:layout_marginStart="8dp" | |
| android:layout_marginTop="8dp"/> | |
| </LinearLayout> | |
| </FrameLayout> |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.constraint.ConstraintLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="@color/colorBackground"> | |
| <EditText | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:inputType="textPersonName" | |
| android:ems="10" | |
| android:id="@+id/etName" | |
| android:layout_marginEnd="8dp" | |
| app:layout_constraintEnd_toEndOf="parent" | |
| android:layout_marginStart="8dp" | |
| app:layout_constraintStart_toStartOf="parent" | |
| android:layout_marginTop="8dp" | |
| app:layout_constraintTop_toTopOf="parent" | |
| android:hint="Имя"/> | |
| <EditText | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:inputType="textPersonName" | |
| android:hint="Компания" | |
| android:ems="10" | |
| android:id="@+id/etCompany" | |
| android:layout_marginEnd="8dp" | |
| app:layout_constraintEnd_toEndOf="parent" | |
| android:layout_marginStart="8dp" | |
| app:layout_constraintStart_toStartOf="parent" | |
| android:layout_marginTop="8dp" | |
| app:layout_constraintHorizontal_bias="0.0" | |
| app:layout_constraintTop_toBottomOf="@+id/etName"/> | |
| <Button | |
| android:text="ОК" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:id="@+id/btnOk" | |
| android:layout_marginBottom="8dp" | |
| app:layout_constraintBottom_toBottomOf="parent" | |
| app:layout_constraintEnd_toEndOf="parent" | |
| android:layout_marginEnd="8dp"/> | |
| <CheckBox | |
| android:id="@+id/cbStats" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="Отправлять статистику" | |
| android:layout_marginBottom="8dp" | |
| app:layout_constraintBottom_toBottomOf="parent" | |
| app:layout_constraintStart_toStartOf="parent" | |
| android:layout_marginStart="8dp"/> | |
| </android.support.constraint.ConstraintLayout> |
This file contains hidden or 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
| package io.github.dvegasa.dialogs | |
| import android.app.Dialog | |
| import android.content.Context | |
| import android.os.Bundle | |
| import android.support.v4.app.DialogFragment | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import android.view.Window | |
| import kotlinx.android.synthetic.main.dialog_4.view.* | |
| /** | |
| * 07.08.2019 | |
| */ | |
| class FullscreenCustomDialogFragment : DialogFragment() { | |
| private lateinit var callback: Callback | |
| interface Callback { | |
| fun dialog4_result(name: String, company: String) | |
| } | |
| override fun onAttach(context: Context) { | |
| super.onAttach(context) | |
| if (context is Callback) { | |
| callback = context | |
| } else { | |
| throw Exception("${activity.toString()} must implement interface ${this}.Callback") | |
| } | |
| } | |
| override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
| super.onCreateView(inflater, container, savedInstanceState) | |
| val view = inflater.inflate(R.layout.dialog_4, container, false) | |
| view.btnOk.setOnClickListener { | |
| callback.dialog4_result( | |
| name = view.etName.text.toString(), | |
| company = view.etCompany.text.toString() | |
| ) | |
| dismiss() | |
| } | |
| return view | |
| } | |
| override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
| val dialog = super.onCreateDialog(savedInstanceState) | |
| dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) | |
| dialog.window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) | |
| return dialog | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment