I want to implement the following design:
These five options are displayed on clicking an imageview.I am implementing this design using dialog.
1.moreOption.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:orientation="vertical"
android:weightSum="1">
<TextView
android:id="@+id/viewContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="View Contacts"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0" />
<TextView
android:id="@+id/archiveChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Archive Chat"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0" />
<TextView
android:id="@+id/deleteChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Delete Chat"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0" />
<TextView
android:id="@+id/markAsUnread"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Mark as unread"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0" />
<TextView
android:id="@+id/emailChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Email Chat"
android:textSize="20sp" />
</LinearLayout>
Below is the code that is displaying dialog on clicking imageview.
ImageView imgMoreOption = (ImageView) view.findViewById(R.id.imgMoreoption);
imgMoreOption.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.more_option);
dialog.show();
}
});
Now on clicking imageview i am getting the following screenshot.
But using dialog ,i am not getting according to the design given as from the top i ma getting much space .Please guide me how to implement the given design .
Edited Code
I have fixed the issue.Actually dialog was displaying the empty title.I have changed the code as given below:
imgMoreOption.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // hide the title bar
dialog.setContentView(R.layout.more_option);
dialog.show();
}
});
moreOption.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:orientation="vertical"
android:weightSum="1">
<TextView
android:id="@+id/viewContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin10"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="View Contacts"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/margin10"
android:background="#c0c0c0" />
<TextView
android:id="@+id/archiveChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin10"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Archive Chat"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/margin10"
android:background="#c0c0c0" />
<TextView
android:id="@+id/deleteChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin10"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Delete Chat"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/margin10"
android:background="#c0c0c0" />
<TextView
android:id="@+id/markAsUnread"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin10"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Mark as unread"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/margin10"
android:background="#c0c0c0" />
<TextView
android:id="@+id/emailChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin10"
android:layout_marginTop="@dimen/margin10"
android:layout_weight=".2"
android:gravity="center_vertical"
android:paddingLeft="@dimen/margin10"
android:text="Email Chat"
android:textSize="20sp" />
</LinearLayout>