码迷,mamicode.com
首页 > 其他好文 > 详细

DialogFragment样式实现

时间:2019-01-25 00:23:58      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:ttext   size   XML   ble   can   view   edittext   注册   分享   

自定义DialogFragment阴影样式
要实现的样式如下:
技术分享图片
主要的问题是底部三个标签图片应如何设置;
实现代码如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="300dp"                     //此处的宽度应设置为实际大小
    android:layout_height="wrap_content"
    android:background="#0000"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/cl_launch"
        android:layout_width="300dp"                //此处的宽度应设置为实际大小
                                                    //否则无法达到相应的效果
        android:layout_height="wrap_content"
        android:background="#fff"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">
        <ImageView
            android:id="@+id/iv_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/arrow_down"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            android:layout_marginTop="15dp"
            android:layout_marginLeft="15dp"/>
        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16sp"
            android:textColor="#de000000"
            android:text="即刻开启见界"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/iv_cancel"
            />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/et_account"
            app:layout_constraintTop_toBottomOf="@+id/tv_title"
            android:layout_marginTop="30dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/et_pwd"
            app:layout_constraintTop_toBottomOf="@+id/et_account"
            android:layout_marginTop="30dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"

            />

        <Button
            android:id="@+id/bt_launch"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@+id/et_pwd"
            android:layout_marginTop="30dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:background="#de000000"
            android:text="登录"
            android:textColor="#ffffff"
            />

        <TextView
            android:id="@+id/tv_register"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="没有账号?请先注册"
            android:textSize="12sp"
            app:layout_constraintTop_toBottomOf="@+id/bt_launch"
            app:layout_constraintRight_toRightOf="parent"
            android:layout_marginRight="30dp"
            android:layout_marginTop="5dp"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginBottom="10dp"
            />
    </android.support.constraint.ConstraintLayout>

    <android.support.constraint.ConstraintLayout
        android:id="@+id/cl_share"
        //此处宽度不能设置为match_parent,虽然父布局的宽度设置为300dp,但实际运行之后发现宽度设置为
        //match_parent后,cl_share会平分整个屏幕的宽度(奇了怪)
        android:layout_width="300dp"                    
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        app:layout_constraintTop_toBottomOf="@+id/cl_launch"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:background="@android:color/transparent"
        >

        <ImageView
            android:layout_width="45dp"
            android:layout_height="45dp"
            app:layout_constraintHorizontal_weight="1"
            android:id="@+id/iv_qq"
            android:src="@drawable/icon_prompt_gift_icon"
            app:layout_constraintLeft_toLeftOf="parent"
            />
        <ImageView
            android:layout_width="45dp"
            android:layout_height="45dp"
            app:layout_constraintHorizontal_weight="1"
            android:id="@+id/iv_weibo"
            android:src="@drawable/type_networkgame_icon"
            app:layout_constraintLeft_toRightOf="@+id/iv_qq"
            app:layout_constraintRight_toLeftOf="@+id/iv_weixin"
            />
        <ImageView
            android:id="@+id/iv_weixin"
            android:layout_width="45dp"
            android:layout_height="45dp"
            app:layout_constraintHorizontal_weight="1"
            android:src="@drawable/type_necessary_icon"
            app:layout_constraintRight_toRightOf="parent"
            />
    </android.support.constraint.ConstraintLayout>
    <View
        android:id="@+id/view_bottom"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="@android:color/transparent"
        app:layout_constraintTop_toBottomOf="@+id/cl_share"
        app:layout_constraintBottom_toBottomOf="parent"
        />

</android.support.constraint.ConstraintLayout>

DialogFragment样式实现

标签:ttext   size   XML   ble   can   view   edittext   注册   分享   

原文地址:https://www.cnblogs.com/Ricardoldc/p/10317542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!