Crouton CustomView with infinite duration

I reflected with crouton, and after creating the customView crouton popup, I noticed 2 things; - the layout is slightly changed during creation and will be fixed if the viewing is updated - there is no way to add a style to make a normal crouton, or I don’t know about it ... Someone please provide a way to make each of these neatly

Creuton creat code:

View crouton_view = getLayoutInflater().inflate(R.layout.crouton_layout, null);
Crouton Date_crounton = Crouton.make(this, crouton_view);
crouton_view.setBackgroundColor(Color.rgb(00, 153, 204));
Date_crounton.show();

Layout Code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/crouton_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<EditText
    android:layout_width="match_parent"
    android:layout_height="50dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#b4b4b4" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/crouton_cancel"
        style="?android:attr/actionButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:gravity="center"
        android:text="Cancel"
        android:textSize="14sp" />

    <ImageView
        android:layout_width="1dp"
        android:layout_height="30dp"
        android:layout_gravity="center_vertical"
        android:background="#b4b4b4" />

    <Button
        android:id="@+id/crouton_ok"
        style="?android:attr/actionButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:gravity="center"
        android:text="OK"
        android:textSize="14sp" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:background="#b4b4b4" />
</LinearLayout>

+4
source share
3 answers

Try using the following code

View customView = getActivity().getLayoutInflater().inflate(R.layout.crouton_addexam, null);
final Configuration CONFIGURATION_INFINITE = new Configuration.Builder().setDuration(Configuration.DURATION_INFINITE).build();
final Crouton crouton = Crouton.make(getActivity(),customView,R.id.btnTest,CONFIGURATION_INFINITE);
crouton.setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_INFINITE).build());
test.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
            crouton.hide();

    }
});
+10
source

I use this code for my Crouton:
you can use this:

final Configuration CONFIGURATION_INFINITE = new Configuration.Builder()
                              .setDuration(Configuration.DURATION_INFINITE)
                              .build();
final Crouton infiniteCrouton;
infiniteCrouton = Crouton.makeText(this, "TEXT", Style.INFO); 
infiniteCrouton.setConfiguration(CONFIGURATION_INFINITE);
infiniteCrouton.setOnClickListener(new View.OnClickListener() {
                                  @Override
                                  public void onClick(View v) {
                                    Crouton.hide(infiniteCrouton);
                                  }
                                });
infiniteCrouton.show();
+4
source

, Style Crouton . Configuration.

, Crouton .

Also, I'm not quite sure that using Crouton as a kind of modal dialogue is a good thing from a UX point of view.

0
source

All Articles