简体   繁体   English

Android-警报对话框设计

[英]Android -alert dialog design

In my application I want to show popup dialog. 在我的应用程序中,我想显示弹出对话框。 I drew sketch for first phase. 我为第一阶段画了草图。 and here what I want: 这是我想要的:

在此处输入图片说明

I was trying to implement this and here is my code: 我正在尝试实现这一点,这是我的代码:

<TableLayout  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"
    android:shrinkColumns="*"
    android:stretchColumns="*" 
    android:background="#ffffff"
    tools:context=".CustomMainActivity" >   
    <TableRow
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:gravity="center_horizontal"
        android:background="#b6006a">  
        <ImageView 
            android:id="@+id/ImageView1"
            android:src="@drawable/icon"            
            android:layout_weight="1"       
            android:padding="10dip" 
            android:adjustViewBounds="true"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:scaleType="fitXY"
            android:gravity="right"/> 

        <TextView
            android:id="@+id/TextView1"
            android:layout_weight="1"
            android:textSize="18dp" 
            android:text="Nava Messenger"           
            android:padding="10dip"
            android:background="#b6006a"
            android:textColor="#fff"
            android:gravity="left"/>  

    </TableRow>
    <TableRow
        android:id="@+id/tableRow0"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">  
        <TextView
            android:id="@+id/TextViewSender"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content"
            android:textSize="18dp"
            android:layout_span="3"
            android:maxLines="1"
            android:background="#fff"
            android:textColor="#000"/>  


    </TableRow>
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">  
        <TextView
            android:id="@+id/TextView2"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content"
            android:textSize="18dp"
            android:layout_span="3"
            android:maxLines="4"
            android:padding="18dip" 
            android:background="#fff"
            android:textColor="#000"/>  


    </TableRow>
    <TableRow
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:gravity="center_horizontal">               
        <EditText
            android:id="@+id/EditText1"             
            android:layout_weight="3"
            android:inputType="textCapWords"
            android:layout_width="0dp"                                 
            android:ellipsize="start"           
            android:gravity="center"
            android:textColor="#b6006a"
            android:hint="Write a message..."/>  
        <ImageButton
            android:id="@+id/ImageButton1"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:adjustViewBounds="true"
            android:background="@null"
            android:scaleType="fitXY"
            android:src="@drawable/send_now"            
            android:gravity="right"/>           
    </TableRow>     

</TableLayout>

And result of this code is : 这段代码的结果是:

在此处输入图片说明

I want to modify something such as: 我想修改以下内容:

  • Decreasing header size(purple area on the top of alert dialog) 减小标题大小(警报对话框顶部的紫色区域)
  • Decreasing image size on header (Real size of logo image is :128*128) 缩小页眉上的图像大小(徽标图像的实际大小为:128 * 128)
  • Decreasing send image (Real size of send image is : 48 * 48) 减小发送图像(发送图像的实际尺寸为:48 * 48)
  • Putting send image and EditText on a row 将发送图像和EditText放在一行上

Any suggestion? 有什么建议吗?

Using LinearLayout Adjust Margin/Padding as required. 使用LinearLayout根据需要调整边距/填充。 change icons aswell. 以及更改图标。 rough layout. 粗略的布局。

<LinearLayout 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"
    android:background="#ffffff"
    android:orientation="vertical"
    tools:context=".CustomMainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#b6006a"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/ImageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:gravity="right"
            android:padding="10dip"
            android:scaleType="fitXY"
            android:src="@android:drawable/ic_dialog_dialer" />

        <TextView
            android:id="@+id/TextView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#b6006a"
            android:gravity="left"
            android:padding="10dip"
            android:text="Nava Messenger"
            android:textColor="#fff"
            android:textSize="18dp" />
    </LinearLayout>

    <TextView
        android:id="@+id/TextViewSender"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff"
        android:maxLines="1"
        android:text="Farhan"
        android:textColor="#000"
        android:textSize="18dp" />

    <TextView
        android:id="@+id/TextView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff"
        android:maxLines="4"
        android:text="FarhanFarhanFarhan"
        android:padding="18dip"
        android:textColor="#000"
        android:textSize="18dp" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/EditText1"
            android:layout_width="0dp"
            android:layout_weight="3"
            android:layout_height="match_parent"
            android:ellipsize="start"
            android:gravity="center"
            android:hint="Write a message..."
            android:inputType="textCapWords"
            android:textColor="#b6006a" />

        <ImageButton
            android:id="@+id/ImageButton1"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:background="@null"
            android:gravity="right"
            android:scaleType="center"
            android:src="@android:drawable/ic_menu_send" />
    </LinearLayout>
</LinearLayout>
  • Use RelativeLayout instead TableLayout, it's much easier to use RelativeLayout. 使用RelativeLayout代替TableLayout,使用RelativeLayout更加容易。
  • Change width and height for image sizes triying other values of ScaleType if it were neccesary. 如有必要,请通过缩放ScaleType的其他值来更改图像大小的宽度和高度。
  • If you want to control header's size, don't use "wrap_content". 如果要控制标题的大小,请不要使用“ wrap_content”。
  • Define colors in values/colors.xml. 在values / colors.xml中定义颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM