What should the code be if I want the kind of interface that is shown in the photo? When I touch the image in the ListView,it should expand (enter image description here) and when I touch anywhere around the image, it should disappear (enter image description here).
try this using custom dialog you can achieve this
create a custom_layout file 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#5a000000"
android:padding="5dp"
android:text="Title"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="#drawable/disha2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_favorite_fill" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_favorite_fill" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_favorite_fill" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_favorite_fill" />
</LinearLayout>
</LinearLayout>
now in activity file add this code for custom dialog
final Dialog filterDialog = new Dialog(this);
filterDialog.setContentView(R.layout.custom_layout);
Window window = filterDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);
filterDialog.show();
ask me in case of any query
Related
Hi I am new to Android and i want to display a circular cancel button on image view for closing the dialog
same as below image on top of the dialog.
Simply this is the code for doing the same.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImgeView
android:id="#+id/filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="your drawable"
android:gravity="center"
android:paddingBottom="25dp"
android:paddingTop="25dp"
android:text="Sort"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:adjustViewBounds="true"
android:paddingTop="-10dp"
android:scaleType="fitStart"
android:src="#drawable/yourdrwable" />
</FrameLayout>
If your parent layout is a RelativeLayout, your button must have the following attributes:
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/your_margin"
android:layout_marginEnd="#dimen/your_margin"
I would like to show Uber type info window that can be opened all time and that can be moved on camera view update and fit to the screen instead of cut or overlap issue.
What I want :
What I have tried:
implementation 'com.google.maps.android:android-maps-utils:0.4+'
custom_marker_infowindow_right.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">
<LinearLayout
android:id="#+id/ll_marker_right"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/iv_marker_right"
android:layout_width="#dimen/markerSize"
android:layout_height="#dimen/markerSize"
android:layout_gravity="center_vertical"
android:contentDescription="#string/app_name"
android:src="#drawable/destination_location" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="center_vertical"
android:contentDescription="#string/app_name"
android:src="#drawable/marker_car"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/layout_shadow"
android:elevation="10dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/tv_timing_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="#drawable/marker_square_hours"
android:fontFamily="#font/montserrat_light"
android:gravity="center_vertical|center"
android:maxLines="4"
android:padding="5dp"
android:textColor="#color/color_FFFFFF"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_address_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#drawable/marker_square_address"
android:fontFamily="#font/montserrat_light"
android:gravity="center_vertical"
android:maxLines="4"
android:padding="5dp"
android:textColor="#color/color_000000"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
MainActivity.java
IconGenerator iconFactory_right = new IconGenerator(mContext);
iconFactory_right.setBackground(null);
View view_right = View.inflate(activity, R.layout.custom_marker_infowindow_right, null);
iconFactory_right.setContentView(view_right);
LinearLayout ll_marker_right = (LinearLayout) view_right.findViewById(R.id.ll_marker_right);
int width_ll_right = ll_marker_right.getLayoutParams().width;
ll_marker_right.setPadding((width_ll_right / 2) - (iv_marker_right.getLayoutParams().width / 2), 0, 0, 0);
mMap.addMarker(markerOptions.position(destinationLocation).anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromBitmap(iconFactory_right.makeIcon("current"))));
What I get :
As we see, I am not getting full marker and marker is getting cut and in some cases it overlaps between two. I have also tried mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 450)); to add padding, but in every case it is not working properly.
So I would like to implement Uber type info window that can be moved on camera view update and fit to the screen.
Any help will be highly appreciated..!! Thanks in advance.
Sorry in advance I need to include a few pictures to make my problem a little easier to understand. I am using a linear layout for my custom rows and it is giving me lots of trouble trying to get the rows to look how I want. Currently it looks like this
Please forgive the quick paint picture I am about to show but it is how I would like the layout to look.
I would like to add the name textbox above the dog picture, and a time stamp textbox above each of the 1 and 2. Whenever I try to add textboxes to display this it really messes with the layout. The textbox above the dog picture always wants to go to the right or left of the dog image and push the image to the middle of the page and the buttons get spread out further. I do not have much experience with this layout I typically do relative layout where I can drag and drop pieces. Any advise or help is greatly appreciated.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="150dip"
android:layout_height="150dip"
android:id="#+id/dogimage"
android:clickable="true"
android:layout_alignParentLeft="true"
android:background="#drawable/dogpic"
android:onClick="sendProfile"
android:scaleType="fitXY" />
<ImageButton
android:layout_width="75dip"
android:layout_height="75dip"
android:id="#+id/dog1num1"
android:background="#drawable/num1"
android:clickable="true"
android:onClick="NumberOne"
android:layout_marginLeft="10dp"
android:layout_marginTop="75dp"
android:scaleType="fitXY" />
<ImageButton
android:layout_width="75dip"
android:layout_height="75dip"
android:id="#+id/dog1num2"
android:background="#drawable/num2"
android:clickable="true"
android:onClick="NumberTwo"
android:layout_marginLeft="10dp"
android:layout_marginTop="75dp"
android:scaleType="fitXY" />
</LinearLayout>
You need to wrap your imageview/textview combo in a LinearLayout. And you should set the imageButton using src, not background. Do it 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="#+id/dogimage"
android:layout_width="150dip"
android:layout_height="150dip"
android:clickable="true"
android:onClick="sendProfile"
android:scaleType="fitXY"
android:src="#drawable/dogpic" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timestamp 1" />
<ImageButton
android:id="#+id/dog1num1"
android:layout_width="75dip"
android:layout_height="75dip"
android:layout_marginLeft="10dp"
android:clickable="true"
android:onClick="NumberOne"
android:scaleType="fitXY"
android:src="#drawable/num1" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timestamp 1" />
<ImageButton
android:id="#+id/dog1num2"
android:layout_width="75dip"
android:layout_height="75dip"
android:layout_marginLeft="10dp"
android:clickable="true"
android:onClick="NumberOne"
android:scaleType="fitXY"
android:src="#drawable/num2" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I'm customizing an alert dialog, with a different UI. Here is an example.
As you can see there are two black bands (highlighted with red rectangulars) I would like to remove.
It weird because the main layout show match the parent one, as you can see from the xml below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lytDialog_takeNowDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/default_side_space"
android:layout_marginRight="#dimen/default_side_space"
android:background="#color/yellow"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:gravity="center"
android:padding="#dimen/default_side_space"
android:text="Are you sure?"
android:textColor="#color/dialog_text_color"
android:textSize="#dimen/dialog_text_size" />
<LinearLayout
android:id="#+id/lytShowAlert_takeNowDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/black_gradient"
android:orientation="horizontal"
android:padding="#dimen/default_side_space" android:visibility="gone">
<CheckBox
android:id="#+id/chkShowAlert_takeNowDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="#string/dont_show_alert"
android:textColor="#android:color/white"
android:textSize="#dimen/dialog_yes_no_size" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<Button
android:id="#+id/no_dialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/space_among_buttons"
android:layout_weight=".5"
android:background="#drawable/yellow_gradient"
android:padding="#dimen/default_side_space"
android:text="No"
android:textColor="#color/dialog_text_color"
android:textSize="#dimen/dialog_yes_no_size" />
<Button
android:id="#+id/yes_dialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/space_among_buttons"
android:layout_weight=".5"
android:background="#drawable/yellow_gradient"
android:padding="#dimen/default_side_space"
android:text="Yes"
android:textColor="#color/dialog_text_color"
android:textSize="#dimen/dialog_yes_no_size" />
</LinearLayout>
Anyone knows the solution to remove them please?
If you want to remove black panel, change the appTheme(Actually dialog theme.).
Dialog with transparent background in Android
I'm actually coding an app for Android and I need some help to do something.
I need to do a kind of popup message with this image: http://img716.imageshack.us/img716/9331/postitz.png. This image must have 2 TextView, one of them is a title and the other one is the message.
I have tried some options like Dialog with its own layout, own style, but the image fills all the screen instead of wrap the content of the TextViews. I have also tried to do it with a new Activity and occurs the same, the Image fills all the screen.
My actual layout is 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"
android:gravity="center_vertical"
android:background="#android:color/white">
<LinearLayout
android:id="#+id/img_postit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/postit"
android:orientation="vertical">
<TextView
android:id="#+id/note_titulo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="30dp"/>
<TextView
android:id="#+id/note_descr"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="30dp"/>
</LinearLayout>
</LinearLayout>
But I have tried with a lot of different combinations, RelativeLayout, FrameLayout, and I cannot find the solution to do this.
Any idea of how to resolve it?.
Thank's for all.
you said you used as a new activity. Did you use android:theme="#android:style/Theme.Dialog in your manifest file?
And be sure that the image is little bit smaller one such that it will be suitable to act as a pop up..
If you used a dialog what exactly is the problem? Didnt you get the dialog as a pop up ?
(i think the image is larger so that it might fill the entire screen)
Create your own class extending dialog.And use layout like following. I use this in one of my apps and the dialog window is wrapped around the buttons :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/background"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/ll2"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="#+id/ll1"
android:gravity="left"
android:orientation="horizontal"
android:paddingBottom="5dp" >
<RadioButton
android:id="#+id/start"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/stop"
android:background="#drawable/start_on"
android:button="#android:color/transparent"
android:checked="true" />
<RadioButton
android:id="#+id/stop"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="#drawable/stop_off"
android:button="#android:color/transparent" />
<RadioButton
android:id="#+id/restart"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/stop"
android:background="#drawable/restart_on"
android:button="#android:color/transparent" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/lltext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/detail_credit"
android:layout_below="#+id/ll2"
android:layout_marginBottom="15dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/startText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/stopText"
android:text="#string/start_server_icon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/stopText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:text="#string/stop_server_icon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/restartText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/stopText"
android:text="#string/restart_server_icon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_below="#+id/lltext"
android:layout_centerHorizontal="true"
android:text="OK" />
</RelativeLayout>
final Dialog dialog_my = new Dialog(FIRST.this,
android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialog_my.setContentView(R.layout.about_us); //<PUT YOUR LAYOUT ID HERE>
TextView date = (TextView) dialog_my.findViewById(R.id.date);
TextView thought = (TextView) dialog_my.findViewById(R.id.thought);
TextView ok = (TextView) dialog_my.findViewById(R.id.ok);
TextView link = (TextView) dialog_my.findViewById(R.id.link);
TextView contact = (TextView) dialog_my.findViewById(R.id.contact);
WindowManager.LayoutParams lp = dialog_my.getWindow().getAttributes();
lp.dimAmount = 0.0f;
dialog_my.getWindow().setAttributes(lp);
dialog_my.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dialog_my.show();