Coloured Background of Action Button in Sweet Alert (Android) - android

I have written some code for showing a Dialog box using sweet alert library. It's a very popular library and contains couple of awesome features which are very useful for designing purpose and developing purpose as well. So please help to change the background color of Action button which are present at the bottom of the dialog box.
I am attaching the screen shot and as well as code. Please help me to fix this issue.
I only want to change the background color of Action Button.
MaterialDialog.Builder builder = new MaterialDialog.Builder(SignInActivity.this)
.title("Sign Up")
.titleColor(Color.BLACK)
.customView(R.layout.custom_dialog_sign_up, true)
.positiveText("Submit")
.negativeText("Cancel")
.positiveColorRes(R.color.black_color)
.negativeColorRes(R.color.gray_btn_bg_color)
.canceledOnTouchOutside(false)
.autoDismiss(false);
final MaterialDialog materialDialog = builder.build();
materialDialog.show();

it is pretty late to respond upon your question but, recently i face this issue and start digging about it on google but found nothing, so i started my own and found this perfect solution code and screen shot attached.
SweetAlertDialog sweetAlertDialogView;
sweetAlertDialogView = new SweetAlertDialog(ctx,SweetAlertDialog.ERROR_TYPE);
sweetAlertDialogView.setTitleText(ctx.getResources().getString(R.string.error_msg_oops_title))
.setContentText("Request failed :" + errMsg + " \n" + ctx.getResources().getString(R.string.error_msg_check_net_connection));
sweetAlertDialogView.show();
Button viewGroup = (Button) sweetAlertDialogView.findViewById(cn.pedant.SweetAlert.R.id.confirm_button);
if (viewGroup != null) {
Log.e(TAG, "showErrorMsg: Button view Found yep");
viewGroup.setBackgroundColor(viewGroup.getResources().getColor(R.color.colorSkyBlueButtonLoader));
} else {
Log.e(TAG, "showErrorMsg: Button view Null :( ");
}
from above logic i update the button color to dark sky blue blue, for any other help you can ask me in comment. i will try to resolve it with my best.

A far more easier way to accomplish this is to just overwrite following color values in your color.xml:
<color name="blue_btn_bg_color">#1976D2</color>
<color name="blue_btn_bg_pressed_color">#1565C0</color>

Related

Is there a way to make a disabled button clickable in Android Studio?

In Android Studio I have a Kotlin project with a button that sends an SMS message. When the Send SMS permission for the app is denied, the button is disabled. When a user clicks the disabled button, I would like to display a toast message to the user:
Toast.makeText(this, R.string.smsDisabled, Toast.LENGTH_LONG).show()
However, after much research I haven't been able to make this disabled button clickable. I have tried things like smsButton.isClickable = true on the button, but it still doesn't work. If it is possible to style the button to simply look like it is disabled, that would work too. My button style is currently set to #style/Widget.MaterialComponents.Button and I haven't had any success in changing the button colors. I have tried applying a background, backgroundTint, custom theme, and creating a custom background like in this question.
I am new to Android Studio so I have limited knowledge and experience. Is there a way to achieve this functionality?
Here is what you can do:
if (isPermissions) {
//keep the button as it is or do what you have to when button is enabled
} else {
//change the button color and maybe icon two
button.setBackgroundColor(ContextCompat.getColor(applicationContext, R.color.grey))
button.setOnClickListner {
//show toast
Toast.makeText(this, R.string.smsDisabled, Toast.LENGTH_LONG).show()
}
}
isClickable only makes it clickable once again if the click is disabled with the same attribute.
Try:
button.isEnabled = true

Put a lottie animation in a Dialog. Android

I'm developing an app in android, and I want to use lottie for a Dialog that could have an animated icon of checked-done or fail. Wellcome some examples or ideas. I guess this is possible.
Thanks
You can do that using the LottieDialog library
Github Repo for examples and documentation : LottieDialog
Code example:
Button button = new Button(this);
button.setText("Ok");
button.setTextColor(Color.WHITE);
button.setAllCaps(false);
int greenColor = ContextCompat.getColor(this, R.color.green);
button.setBackgroundTintList(ColorStateList.valueOf(greenColor));
LottieDialog dialog = new LottieDialog(this)
.setAnimation(R.raw.success_like)
.setAnimationRepeatCount(LottieDialog.INFINITE)
.setAutoPlayAnimation(true)
.setDialogBackground(Color.WHITE)
.setMessage("Task is Done :D")
.setMessageColor(greenColor)
.addActionButton(button);
dialog.show();
You can add more buttons, or create it with no buttons,

How to achieve custom dialog at the bottom of the screen in Android

Which component do I choose to achieve custom dialog at the bottom as shown in the below image? Shall I choose alertdialog,popupwindow, or fragmentdialog?
Try this
BottomSheetDialog dialog = new BottomSheetDialog(YourActivity.this);
dialog.setContentView(YourView);
dialog.show();
Edit: I didn't there was a built in component in Android to do so. Good to know! Also, check this out:
https://medium.com/glucosio-project/moving-from-dialogs-to-bottomsheetdialogs-on-android-15fb8d140295#
I would recommend FragmentDialog without a doubt.
It's so much easier to create a customized Dialog regarding location & layout design.
Kotlin code for run custom ButtomSheetDialog (run inside Activity)
var CustomSelectProfilePicBottomSheetDialog = BottomSheetDialog(this)
val layoutButtomSheetView = this.layoutInflater.inflate(R.layout.ly_custom_buttom_sheet_frg_dialog, null)
CustomSelectProfilePicBottomSheetDialog.setContentView(layoutButtomSheetView)
CustomSelectProfilePicBottomSheetDialog.show()

Android, How to use animation in order to show blinking?

In my application, I have recording button. I want when user clicks on it each one second i change the background in order to simulate blinking. I created a handler and set it to 1 second therefore each one second this handler runs. Here i change the background. this my code:
mUpdateUITimerTask = new Runnable() {
public void run() {
// Simulating blinking for capture button
if(bolToggle) {
bolToggle = false;
captureButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_record_blink));
} else {
bolToggle = true;
captureButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_record));
}
mHandler.postDelayed(mUpdateUITimerTask, 1000);
}
};
When I run the app i see the changes but its not clear. buttons are like this:
When i run the application, red image is showing ok but for white image, it shows red image with a little white halo around it.
I tried to put captureButton.setBackgroundColor(Color.TRANSPARENT); before setting background but result was same.
any suggestion would be appreciated. Thank you.
Found the answer you need: https://stackoverflow.com/a/4852468/1352556
Basically you want an alpha animation. I believe this will make the entire button flash however, do you only want the red dot flashing?

android progressbar white circle

Hi im invoking a simple progress bar in android with the following code
MyDialog = ProgressDialog.show(attraction_more_info.this, " " ,
" Loading. Please wait ... ", true);
The thing is when it comes up there is a small white circle with a white triangle in it above the spinning icon. How do i get rid of this so it is only the spinning circle and the text.
it looks like the following image although myne does not say the "indeterminate" part.
(source: lytsing.org)
Probably something simple to get rid of it.
Thanks
Remove the space in between the "" after attraction_more_info.this. It's the title. You can enter anything within the double quotes but its optional. E.g. Retrieving Information
From this:
MyDialog = ProgressDialog.show(attraction_more_info.this, " " ,
" Loading. Please wait ... ", true);
Into this:
MyDialog = ProgressDialog.show(attraction_more_info.this, "" ,
" Loading. Please wait ... ", true);
Go for this instead,
MyDialog = ProgressDialog.setMessage("Loading. Please wait...");
This will provide you with your expected result.

Categories

Resources