[英]Place a button outside my layout on DialogFragment
First of all, take a look at this screeshot: 首先,看一下下面的脚本:
I want to place a close button in this modal like this: 我想在此模式中放置一个关闭按钮,如下所示:
But I can't figure out how to do that, here is going my layout file: 但是我不知道该怎么做,这是我的布局文件:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="br.com.makadu.makaduevento.ui.fragments.wizardInteligenceArtificial.WizardAIFifthStep">
<android.support.constraint.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_title_subjects_schedule_suggestion"
android:paddingTop="@dimen/screen_title_top_bot_padding"
android:paddingBottom="@dimen/screen_title_top_bot_padding"
android:background="@color/Verde2"
android:gravity="center_horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="@dimen/txt_medium"
android:text="@string/str_screen_title_subjects"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:text="@string/str_according_to_your_interests_title"
style="@style/Theme.DefaultTextView.PrimaryDark.Bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
android:id="@+id/tv_according_interests"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/tv_title_subjects_schedule_suggestion" />
<ExpandableListView
android:id="@+id/elv_suggested_schedule"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/tv_according_interests"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/b_confirm_schedule">
</ExpandableListView>
<Button
android:id="@+id/b_confirm_schedule"
style="@style/Theme.DefaultButton.Purple.Radius"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/str_confirm_schedule_button"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="8dp" />
</android.support.constraint.ConstraintLayout>
Thanks in advance. 提前致谢。 Well stackoverflow is asking me to explain better my problem, but i guess the pictures explain it selfs, so I'm now just writing any no sense text.
好了,stackoverflow要求我更好地解释我的问题,但是我想这些图片说明了它本身,所以我现在只写任何没有意义的文本。
The first solution , it will work 100% but I think not beautiful: 第一个解决方案 ,它将100%工作,但我认为效果不佳:
You can make root layout transparent and put in it needed visible views. 您可以使根布局透明,并在其中放置所需的可见视图。 U can set
OnClickListener
for root view to hide dialog on tap out visible views. U可以将
OnClickListener
设置为根视图,以在点击可见视图时隐藏对话框。
The second solution , maybe it will work I can't check now: 第二种解决方案 ,也许可以用,现在我无法检查:
You can turn off clipPadding
for root view and move yo close button out of visible. 您可以关闭用于根视图的
clipPadding
并将“关闭”按钮移到不可见的位置。
PS I wrote from phone so it has not good view format and without samples. PS我是用手机写的,所以它的查看格式不好,没有样本。
I runed on similar issue, u should Create a LinearLayout With a gravity center and margin with background transparent, the add a RelativeLayout with the content of your dialog. 我在类似的问题上运行过,您应该创建一个带有重心和具有透明背景的边距的LinearLayout,并添加一个带有对话框内容的RelativeLayout。
In the RelativeLayout u can use the android:layout_alignParentRight="true" & android:layout_alignParentTop="true" for the ImageView containing the close button (probably u will need to use some margins too) so it will be displayed above the textview containing the title of your dialog. 在RelativeLayout中,您可以对包含关闭按钮的ImageView使用android:layout_alignParentRight =“ true”和android:layout_alignParentTop =“ true” (可能您也需要使用一些边距),以便将其显示在包含对话框的标题。
I hope this helped you, tomorrow i will try to send ua code for this ! 希望对您有所帮助,明天我将尝试为此发送UA代码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.