【问题标题】:I want to build Custom ListView in android. Screen Attached [closed]我想在 android 中构建自定义 ListView。附加屏幕[关闭]
【发布时间】:2017-08-01 09:20:39
【问题描述】:

我怎样才能做到这一点。应该用什么, 对话框、Snackbar 或带有动画的弹出窗口。我必须显示此图像中的列表项。

【问题讨论】:

  • 你可以通过动画使用对话框
  • 好的。但为什么对这个问题投了反对票?
  • 选择了一个对话框,然后是一个线性布局,然后根据需要扩展您的视图。
  • @UmairIqbal 我想你直接问了问题。你没有发布你到目前为止所做的事情。用你的努力提出问题..
  • 我没有要代码。我在问建议,大声笑。我现在正在删除问题。

标签: android xml android-layout listview


【解决方案1】:

您可以将 Dialog Fragment 或 Bottom sheet 与 Recycler 视图一起使用。在什么是应用程序中,我认为底部表的使用有很多限制。

因此,对于带有 Recycler 视图的底部工作表,您可以查看 thisthis

对于对话框片段,您可以查看this,了解如何在底部显示对话框。

希望能帮到你……

【讨论】:

    【解决方案2】:

    你可以试试这个,你可以使用带有动画的对话框,你可以创建带有动画的对话框,在对话框显示时向上滑动,在对话框关闭时向下滑动

    像这样创建对话框

    final Dialog customDialog = new Dialog(context, R.style.DialogSlideAnim);
    customDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    customDialog.setContentView(R.layout.custom_dialog_filter);
    customDialog.setTitle("");
    Window window = customDialog.getWindow();
    window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    window.setGravity(Gravity.BOTTOM);
    customDialog.show();
    

    在 style.xml 中创建这个主题

     <style name="DialogAnimation">
        <item name="android:windowEnterAnimation">@anim/anim_slide_up</item><!--animation file-->
        <item name="android:windowExitAnimation">@anim/anim_slide_down</item><!--animation file-->
        <item name="android:windowFrame">@null</item><!--frame-->
        <item name="android:windowNoTitle">true</item>
    </style>
    
    <!-- Animation for dialog box -->
    <style name="DialogSlideAnim">
        <item name="colorPrimaryDark">@android:color/transparent</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item> <!--shadow-->
        <item name="android:windowIsFloating">false</item>
        <item name="android:backgroundDimEnabled">true
        </item> <!-- true:  create shadow effect when open dialog -->
        <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
    </style>
    

    现在创建类似 anim_slide_up 的动画文件

    <?xml version="1.0" encoding="utf-8"?>
    
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
    android:fromYDelta="50%p"
    android:toYDelta="0%p" />
    

    现在创建类似 anim_slide_down 的动画文件

    <?xml version="1.0" encoding="utf-8"?>
    
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="50%p"
    android:duration="@android:integer/config_longAnimTime"/>
    

    如有任何疑问,请咨询我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-27
      • 2011-12-23
      • 1970-01-01
      • 2016-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多