我一直在思考 crouton,在创建 customView crouton 弹出窗口后,我注意到了两件事;
- 布局在创建时略有修改,如果 View 更新,则会更正
- 无法添加样式来制作自定义面包丁,或者我不知道......
有人可以提供一种方法来整齐地完成每一个
油炸面包丁创建代码:
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();
布局代码:
<?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>
最佳答案
尝试使用以下代码
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();
}
});