Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crouton CustomView with infinit duration

I have been pondering with crouton, and after creating a customView crouton popup I have noticed 2 things; - the layout is slightly modified upon creation and would be corrected if the view if updated - there is no way of adding a style to make custom crouton, or no way I know of ... Would someone please provide a way to do each of these neatly

Crouton 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>

like image 847
alk Avatar asked Dec 08 '22 11:12

alk


2 Answers

Try to use this 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();

    }
});
like image 179
lance_andrew Avatar answered Dec 23 '22 20:12

lance_andrew


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();
like image 30
Mostafa Rostami Avatar answered Dec 23 '22 20:12

Mostafa Rostami