Search code examples
androidandroid-layoutview

View to Show Third Party Licenses in Android App


I'm new to Android App Development and was studying about various views. There was a particular view which caught my attention and is used in Google Play Music Android App

Screenshot

I think it is a PopUpWindow but not fully sure. How can we achieve this kind of View and customize the text inside it?


Solution

  • It is a custom dialog my friend. Follow these steps to create your own custom dailog:

    step 1 :-> create a layout file custom_layout in res/layout folder like this

    <?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:orientation="vertical">
    
    <TextView
        android:id="@+id/tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="10dp"
        android:text="hello world" />
    
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="10dp"
        android:text="hello world" />
    
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="10dp"
        android:text="hello world" />
    
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@mipmap/ic_launcher" />
    

    step :-> 2 create a dialog like this in your activity java file

     Dialog custoDialog = new Dialog(MainActivity.this);
        custoDialog.setContentView(R.layout.custom_layout);
    
        Window window = custoDialog.getWindow();
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
        window.setGravity(Gravity.CENTER);
    
    
        // acces you custom dialog controlss like this
        TextView tv = (TextView) custoDialog.findViewById(R.id.tv);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //perfom actions here
            }
        });
        custoDialog.show();
    

    ask me in case of any query