Show Notification in full screen - android-notifications

I want create custom ui notification and show it full screen. How can I do it.
<LinearLayout>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="#drawable/icon_image" />
<TextView
android:id="#+id/alarm_text"
style="#style/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:text="#string/in_progress" />
<RelativeLayout
android:id="#+id/sticky_header"
android:layout_width="match_parent"
android:layout_height="#dimen/eader_height"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:id="#+id/sticky_text"
style="#style/normal_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="#string/message" />
<TextView
android:id="#+id/button"
style="#style/white"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/msg_selector"
android:gravity="center"
android:text="#string/msg" />
</RelativeLayout>
</LinearLayout>
I know there are RemoteViews we could use, but I am not sure how to set it up to NotificationCompat.Builder
Also I need to take action(launch activity) when the user presses the button in id -> button

Related

android studio: center ProgressPar on top of RoundedImageView

I'm working on a chat app where users can send Texts/Images to another user. so if the sender is the current user then the messages(text/Image) will appear on the right of the page. and if the current user is the receiver then messages appear on left. Like this:
I want to add progressBar on the centre of the image on both sides. (for loading image purposes).
Here is the XML of the right-side:
<RelativeLayout
android:layout_width="#dimen/_280sdp"
android:layout_alignParentEnd="true"
android:layout_height="wrap_content">
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/imageIV"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:layout_alignParentEnd="true"
android:adjustViewBounds="true"
app:riv_corner_radius="15dp"
android:layout_below="#+id/date"
android:src="#drawable/ic_baseline_image_24"
/>
<ProgressBar
android:visibility="gone"
android:id="#+id/pb"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/imageIV"
android:layout_alignBottom="#+id/imageIV"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="85dp"
android:layout_marginTop="85dp"
android:layout_marginEnd="85dp"
android:layout_marginBottom="85dp" />
<LinearLayout
android:orientation="vertical"
android:id="#+id/message_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageIV"
android:padding="#dimen/_5sdp"
android:layout_alignParentEnd="true"
android:background="#drawable/background_right"
android:layout_marginTop="10dip">
<TextView
android:id="#+id/show_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:visibility="gone"
android:textSize="18sp"
android:textColor="#fff"
android:paddingLeft="5dp"
android:paddingRight="5dp"/>
<TextView
android:id="#+id/messageTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="time"
android:textColor="#fff"
android:textSize="10dp" />
</LinearLayout>
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date"
android:layout_alignParentEnd="true"
android:textColor="#AEAEAE"
android:paddingEnd="#dimen/_5sdp"
android:textSize="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txt_seen"
android:paddingTop="#dimen/_5sdp"
android:layout_below="#+id/message_wrapper"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
and Here is the XML of the Left-side:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="#dimen/_280sdp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="5dp"
android:id="#+id/messageLayout"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="#dimen/_3sdp"
android:src="#drawable/pl"/>
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/imageIV"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:layout_toEndOf="#+id/profile_image"
android:adjustViewBounds="true"
app:riv_corner_radius="15dp"
android:layout_below="#+id/date"
android:src="#drawable/ic_baseline_image_24"
/>
<ProgressBar
android:id="#+id/pb"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/imageIV"
android:layout_alignBottom="#+id/imageIV"
android:layout_marginStart="85dp"
android:layout_marginTop="85dp"
android:layout_marginEnd="85dp"
android:layout_marginBottom="85dp" />
<LinearLayout
android:id="#+id/message_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/_5sdp"
android:layout_below="#+id/imageIV"
android:layout_toEndOf="#id/profile_image"
android:background="#drawable/background_left"
android:layout_marginTop="10dip">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/show_message"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="18sp"
android:text="Hello"
android:paddingLeft="5dp"
android:paddingRight="5dp"
/>
<TextView
android:id="#+id/messageTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="time"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textSize="8dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date"
android:layout_toRightOf="#+id/profile_image"
android:textColor="#AEAEAE"
android:paddingRight="#dimen/_5sdp"
android:textSize="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txt_seen"
android:paddingTop="#dimen/_5sdp"
android:visibility="gone"
android:layout_below="#+id/message_wrapper"
/>
</RelativeLayout>
How can I do this? please help.
You can add extra progress layout_alignEnd/layout_alignTop attributes for right layout:
<ProgressBar
android:id="#+id/pb"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/imageIV"
android:layout_alignBottom="#+id/imageIV"
android:layout_alignEnd="#+id/imageIV"
android:layout_alignTop="#+id/imageIV" />
and layout_alignTop/layout_alignEnd for the left layout:
<ProgressBar
android:id="#+id/pb"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignStart="#+id/imageIV"
android:layout_alignBottom="#+id/imageIV"
android:layout_alignTop="#+id/imageIV"
android:layout_alignEnd="#+id/imageIV"
/>

How to constrain a ScrollView with dynamic contents?

<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteY="25dp">
<TableLayout
android:id="#+id/tableLayoutHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textViewDeviceName">
</TableLayout>
<ScrollView
android:id="#+id/scrollViewLayoutFoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:minWidth="150dp"
android:minHeight="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableLayoutHeader">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/red"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayoutFragments1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" />
<LinearLayout
android:id="#+id/linearLayoutFragments2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"></LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
linearLayoutFragments1 and linearLayoutFragments2 have many fragments added at runtime. Unfortunately, scrollViewLayoutFoo is not constrained below tableLayoutHeader, but overflows into tableLayoutHeader.
Could anyone offer a tip on how to fix this?
You were missing some constraints.
You need to constraint the TabLayout to the parent from start/top/end and scroll view constraint to the bottom of it.
There are also referenced some views that are not in the example so you might have to update them accordingly.
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="#+id/tableLayoutHeader"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_height="48dp" />
<ScrollView
android:id="#+id/scrollViewLayoutFoo"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:minHeight="60dp"
android:minWidth="150dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableLayoutHeader">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayoutFragments1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<LinearLayout
android:id="#+id/linearLayoutFragments2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>

Line up text under each other in Layout

I have created a payment info screen but would like to adjust it to make it look more like the image below. I have added below my attempted code. How do I go about doing this? Any help would be greatly appreciated. I would like to know how to split the layout into 3 sections and have buttons like the image. Also how would I align my text to be under each other?
Image of what I would like to achieve
Code Below
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/colorPrimary"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/solver"/>
<View
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Record phone calls"
android:textColor="#color/colorWhite"
android:layout_gravity="center"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Know who viewed your profile"
android:textColor="#color/colorWhite"
android:layout_gravity="center"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option to view profiles privately"
android:textColor="#color/colorWhite"
android:layout_gravity="center"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get the Premium badge on your profile"
android:textColor="#color/colorWhite"
android:layout_gravity="center"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30 contact requests a month"
android:layout_gravity="center"
android:textColor="#color/colorWhite"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No ads"
android:layout_gravity="center"
android:textColor="#color/colorWhite"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Monthly Premium R19,19"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yearly Premium R179,99"/>
</LinearLayout>
</ScrollView>
Don't use scrollView. Use a vertical LinearLayout and give it's children suitable weights
Something Like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:weight="1.25">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:weight="1"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
And for transparensy use this style for your activity in manifest
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#66000000</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowFullscreen">true</item>
</style>

how to add textview and two buttons below textview in cardview xamarin

I have to add tetxview and two buttons inside cardview in such way that,
the two buttons should be on single line and below textview.
also please check below code for reference
here is my code
<FrameLayout xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Caption"
android:id="#+id/textQuestion"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp" />
<Button
android:id="#+id/btnAnswer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Expalantion"
/>
<Button
android:id="#+id/btnVideo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="video"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>

Android - Displaying an additional layout underneath an ImageView when using Picasso's fit() and centerInside()

Below is an ImageView that can't 'wrap_content' on the height and width as it is displaying the image using Picasso's fit() and centerInside() attributes.
Due to this, I have to either set a height in dp or state 'match_parent'. If I set a specific height in dp my Button will display but this isn't ideal for different sizes screens of course. If I set 'match_parent' the ImageView fills the rest of the screen and I can't display my Button underneath the ImageView.
Does anyone know of a way to nest my ImageView in some way so I can display my final Button?
Also, I can't work out how to align my picture of the top of the ImageView, please help with this as well if you can.
main_activity.xml.
<?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="match_parent"
android:background="#color/colorBackground">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/Toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:minHeight="?attr/actionBarSize" />
<LinearLayout
android:id="#+id/button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/toolbar"
android:padding="10dp">
<Button
android:id="#+id/button_kitty"
style="#style/Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/button_kitty" />
<Space
android:id="#+id/space"
android:layout_width="10dp"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button_cat"
style="#style/Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/button_cat" />
</LinearLayout>
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/button_layout"
android:layout_marginBottom="17dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="4dp"
android:adjustViewBounds="true" />
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/button_layout"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:indeterminate="true"
android:visibility="invisible" />
<Button
android:id="#+id/button_facebook"
style="#style/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/image"
android:layout_centerHorizontal="true"
android:gravity="center" />
ActivityMain.java
#Override
public void onResponse(Call<KittyCatModel> call, Response<KittyCatModel> response) {
KittyCatModel model = response.body();
String url = model.getSource();
Picasso.with(this)
.load(url)
.fit()
.centerInside()
.into(imageView, this);
}
On Picasso's github, there's a thread regarding fit() not working when an imageView has adjustViewBounds set to true. Remove either one and see how it goes (I'm doing this from mobile, so can't test it before answering, sorry).
Here's a link to that thread:
https://github.com/square/picasso/issues/425
That thread links to another thread on Picasso's git regarding creating a custom imageView to make this work the way you want
Here's a link to that thread:
https://github.com/square/picasso/issues/457
Had some offline assistance with this issue, answer is:
This is nothing to do with Picasso, it is just an XML issue.
The ImageView and ProgressBar needed to be in a RelativeLayout within a
LinearLayout so I could apply layout_weight=“1” to that RelativeLayout.
This allowed me to “match_parent” on my ImageView width and height so
the image fills its layout but doesn’t hide the bottom button.
Hope that helps somebody else in the future.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/color_background"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/Toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:minHeight="?attr/actionBarSize" />
<LinearLayout
android:id="#+id/button_layout_generate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/toolbar"
android:orientation="horizontal"
android:padding="12dp">
<Button
android:id="#+id/button_kitty"
style="#style/Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/button_kitty" />
<Space
android:id="#+id/space"
android:layout_width="10dp"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button_cat"
style="#style/Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/button_cat" />
</LinearLayout>
<RelativeLayout
android:id="#+id/image_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/button_layout_generate"
android:layout_weight="1"
android:paddingRight="16dp"
android:paddingLeft="16dp">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true" />
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"
android:visibility="invisible" />
</RelativeLayout>
<LinearLayout
android:id="#+id/button_layout_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/image"
android:orientation="horizontal"
android:padding="12dp">
<Space
android:id="#+id/space_left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<Button
android:id="#+id/button_facebook"
style="#style/Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#id/image"
android:layout_weight="1"
android:enabled="false"
android:gravity="center"
android:text="#string/button_facebook" />
<Space
android:id="#+id/space_right"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>

Resources