Friday, 8 September 2017

Simple Dialog box


step 1:
dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
android:layout_width="match_parent"    
android:layout_height="match_parent"    
android:background="#eee7dd"    
android:layout_gravity="center"    
android:gravity="center"    
android:orientation="horizontal" >

    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:layout_gravity="center"        
android:gravity="center"        
android:orientation="vertical">

    <ImageView        
android:layout_width="50dp"        
android:layout_height="50dp"        
android:background="@drawable/call"/>
        <View            
android:layout_width="match_parent"            
android:layout_height="5dp"/>
        <TextView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:text="Call"            
android:textColor="@android:color/black"            
android:textSize="15dp"/></LinearLayout>
    <View        
android:layout_width="20dp"        
android:layout_height="match_parent"/>
    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_gravity="center"        
android:gravity="center"        
android:layout_height="wrap_content"        
android:orientation="vertical">

        <ImageView            
android:layout_width="50dp"            
android:layout_height="50dp"            
android:background="@drawable/chat_message"/>
        <View            
android:layout_width="match_parent"            
android:layout_height="5dp"/>
        <TextView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:text="Message"            
android:textColor="@android:color/black"            
android:textSize="15dp"/></LinearLayout>
    <View        
android:layout_width="20dp"        
android:layout_height="match_parent"/>
    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_gravity="center"        
android:gravity="center"        
android:layout_height="wrap_content"        
android:orientation="vertical">

        <ImageView            
android:layout_width="50dp"            
android:layout_height="50dp"            
android:background="@drawable/whats_app"/>
        <View            
android:layout_width="match_parent"            
android:layout_height="5dp"/>
        <TextView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:text="WhatsApp"            
android:textColor="@android:color/black"            
android:textSize="15dp"/></LinearLayout>
    <View        
android:layout_width="20dp"        
android:layout_height="match_parent"/>
    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_gravity="center"        
android:gravity="center"        
android:layout_height="wrap_content"        
android:orientation="vertical">

        <ImageView            
android:layout_width="50dp"            
android:layout_height="50dp"            
android:background="@drawable/profile_view"/>
        <View            
android:layout_width="match_parent"            
android:layout_height="5dp"/>
        <TextView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:text="Profile"            
android:textColor="@android:color/black"            
android:textSize="15dp"/></LinearLayout>
    </LinearLayout>

step 2:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_width="match_parent"    
android:orientation="vertical"    
android:layout_height="match_parent">
 
            <ImageView                
android:id="@+id/click"                
android:layout_width="30dp"                
android:layout_height="30dp"                
android:layout_gravity="end"                
android:layout_marginRight="10dp"                
android:layout_marginBottom="40dp"                
android:background="@drawable/image"/>
       </LinearLayout>
step 3:
CustomCotactDialog.java
public class CustomContactDialog extends Dialog {
    public Context c;
    public Dialog d;
    public CustomContactDialog(@NonNull Context context) {
        super(context);
        c=context;
    }



    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_contact);

    }
}
step 4:
DialogActivity.java
public class DialogActivity extends AppCompatActivity {
    Context context;
    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);
        final ImageView imageView=(ImageView)findViewById(R.id.click);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                CustomContactDialog customDialog=new CustomContactDialog(context);
                customDialog.show();
            }
        });
    }
}

No comments:

Post a Comment

HOW TO CREATE CIRCLE IMAGE VIEW

Step 1: implementation 'de.hdodenhof:circleimageview:3.0.0' Step 2: <de.hdodenhof.circleimageview.CircleImageView xmlns:ap...