pni*_*zle 10 android native uiactionsheet ios react-native
iOS SDK中UIActionSheet的Android等价是什么?我正在研究React-Native项目,并且需要尽可能保持本机控件的使用.我没有遇到使用相应的plartform'动作表'的npm包或其他包.他们似乎都使用iOS中的原生动作表,以及Android的iOS动作表的javascript模拟(这使得它在Android上非原生).如果我能知道android显示哪个iOS显示动作表,那么我可以使用适用于Android的RN Android组件和iOS的动作表.我希望这是一个明确的问题.
我们用来BottomSheetDialog
在Android中做同样的工作.与iOS相比,不完全相同,可能需要更多代码才能编写.但最终结果是相似的.
参考文献:
https://developer.android.com/reference/android/support/design/widget/BottomSheetDialog.html https://medium.com/glucosio-project/15fb8d140295
我已经BottomSheetDialog
在Android中实现了类似的功能。
BottomSheetDialog mBottomDialogNotificationAction;
private void showDialogNotificationAction() {
try {
View sheetView = mActivity.getLayoutInflater().inflate(R.layout.dialog_bottom_notification_action, null);
mBottomDialogNotificationAction = new BottomSheetDialog(mActivity);
mBottomDialogNotificationAction.setContentView(sheetView);
mBottomDialogNotificationAction.show();
// Remove default white color background
FrameLayout bottomSheet = (FrameLayout) mBottomDialogNotificationAction.findViewById(android.support.design.R.id.design_bottom_sheet);
bottomSheet.setBackground(null);
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
dialog_bottom_notification_action.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Apply Leave"
android:textColor="#1E82FF"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#E5E5E5" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Regularisation"
android:textColor="#1E82FF"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/rounded_corner"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Close"
android:textColor="#1E82FF"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
rounded_corner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff" />
<corners android:radius="@dimen/size_10dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10228 次 |
最近记录: |