ConstraintLayout Notification Badge - android

Regarding ConstraintLayout Notification Badge
I have used ConstraintLayout for notification as shown below.
here i used ImageButton and textview
out put:
here i used Button and textview
output :
insted of imageview is used button then it look like this.
can any help me to solve this in constraintLayout.
ex :
when i tryed with button it displaying like this .
one more new thing i got to know if you are using FrameLayout or RelativeLayout display badge is working fine for both Button , ImageView or ImageButtom.
But on long-press or click of Button Notification badge is going back , in Imageview and imagebutton it working fine.

This happens, because Button has its own elevation.
Higher elevation, gets views to the front.
Try adding higher elevation to your Badge like below.
android:elevation="10dp"
And, you don't want to scale your Image, you must use ImageView or ImageButton.

Use this style="?android:attr/borderlessButtonStyle" in the Button xml
<Button
style="?android:attr/borderlessButtonStyle"
android:background="#mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

Final i got the solution for the above question
1 : for Button
android:elevation will not effect beacuse internal it has elevation.
instead of elevation use android:stateListAnimator="#null"
2 : for other then button elevation will work

Related

Scrollable textview black when pressed?

I created a textview that if the text is to long it will make it scrollable. However if you click on it or hold your finger on it, it will turn black like its been clicked. does anyone know the code to make it not click-able but still be able to scroll? thank you!
defined the rest in my xml:
TextView Dark=(TextView)findViewById(R.id.Quote);
Dark.setMovementMethod(new ScrollingMovementMethod()) ;
Just disable the TextView (enabled=false) and it will still be scrollable. To overcome the gray text that shows by default in a disabled TextView, set the textColor explicitly.
<TextView
...
android:enabled="false"
android:textColor="#FFFFFFFF"
...
>

How to bring an image to front?

I'm translating an image from somewhere to another, and where it goes there is a button. But i want it to be unclickable when the image's over it! It's not seen but still can be clicked! How can i bring the image to front, so the button will not be worked? Thanks in advance.
Implement setAnimationListener in your translate animation and in onAnimationStart(Animation animation) put your bringToFront() method. It does work for me.
Try this:
Button btn = (Button)findViewById(R.id.my_btn);
btn.setEnabled(false);
I think it could help if you make that the ImageView clickable.
This could be achieved by:
Setting the clickable attribute (http://developer.android.com/reference/android/view/View.html#attr_android:clickable) to true in the layout XML
Invoking setClickable(true) (http://developer.android.com/reference/android/view/View.html#setClickable%28boolean%29) on the ImageView object in your code
Change the order of your xml file. The Views that are listed first will be behind the Views that are listed after them.
<ImageView android:id="#+id/iv01"/>
<Button android:id="#+id/btn01"/>
In the code above the button will be placed on top of the ImageView.
<Button android:id="#+id/btn01"/>
<ImageView android:id="#+id/iv01"/>
In the code above the ImageView will be placed on top of the Button.
You can also hide the Button from the layout in your .java (Activity) file.
Button btn = findViewById(R.id.btn01);
btn.setVisibility(View.GONE);
Also you can set the Butt

How to create an ImageButton with an overlayed image?

I have a button that starts out as a placeholder, but once the user authenticates, it changes to a custom image for that user.
<ImageButton android:id="#+id/button"
android:background="#null"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/button_default"/>
And then later:
ImageButton ib = (ImageButton)findViewById(R.id.button);
ib.setImageBitmap(previouslyDecodedBitmap);
But this looks terrible. I can't figure out how to style it properly so that the newly decoded bitmap is the right size and behaves like an ImageButton. I suspect there is some combination of widgets I can use other than ImageButton to achieve this? I was hoping I could just nest an ImageView on top of the ImageButton by adding it as a child to ImageButton, but that doesn't seem to be allowed (it is in Silverlight...).
Anyway, any suggestions on how to properly do this are welcome. Thanks.
One way would be to use frame layout and place buttons and image one over the other , top being imageview , keep it invisible (android:visibility = "invisible")
On clicking the button and authenticating , make it visible over the button or else even you can hide the button below and show only image on top.

Android button dynamically placed on button

I wanted to know if there is a way to place a button on the bottom of the screen, no matter what size screen the device has. I basically want the button to have a gravity="bottom", not just its text. I have been trying to do this, and I cannot find a way to do it. any suggestions?
What layout is the button in? Using a relative layout, you can set the button to align_parent_bottom.
use a RelativeLayout with layout_height="fill_parent" then set the button's layout_alignParentBottom value to true in the XML file
Never mind, I created a child LinearLayout only for and I put
android:gravity="bottom"
in the child and it worked :-)
Try using android:layout_gravity="bottom" on the Button :)

Displaying popup images on button click

Please refer the image given in the url
http://docs.google.com/Doc?docid=0AQhgDtGvE2HgZGZ6cmtua185M2RneG5nYmNm&hl=en
My query is, How can I display the messages corresponding to the rounded buttons and the table row , when I click on the rounded button with question mark.
I know, I have to use listener for the ? button , but what should I do in listener exactly, such that when I click, it shows those alerts(images) and when I click again, it disappears.
For this UI, I have used Relative layout as was suggested here -- Aligning components at desired positions -- and it worked perfect for me.
So, do I need to change my base layout altogether for accomplishing this?
You can use a FrameLayout as the base for your ui layout and then add an ImageView overlay. For example:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/MainFrame"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Put your normal layout stuff here -->
</FrameLayout>
Then in your code you can create the ImageView and add it to the MainFrame and it will overlay your UI, like this:
FrameLayout mainFrame = (FrameLayout)findViewById(R.id.MainFrame);
ImageView overlay = new ImageView(this);
overlay.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.overlay));
mainFrame.addView(overlay);
Then later you can call:
mainFrame.removeView(overlay);
to have it go away.

Categories

Resources