小编Iro*_*som的帖子

在zip上播放.mp4文件而不提取zip

在SD卡上,我有一个包含一个视频文件(.mp4)的zip文件.我需要通过VideoView播放该视频文件而不提取zip.

到目前为止,我尝试过:

ZipFile zipFile = new ZipFile(new File("/sdcard/checking.zip"));
ZipEntry zipEntry = zipFile.getEntry("checking.mp4");
InputStream inStream  = zipFile.getInputStream(zipEntry);
Run Code Online (Sandbox Code Playgroud)

但我找不到任何播放视频的API InputStream.zipEntry.getSize()确实返回了值.

我试着videoView.setVideoURI(Uri.parse("//sdcard/checking.zip!/checking.mp4"));这里开始

但它显示"无法播放视频".那么我如何在android上做到这一点(在标题中提到).

zip android android-videoview

10
推荐指数
1
解决办法
2248
查看次数

Android:Custom AlertDialog

我已通过以下代码创建了自定义alertdialog:

AlertDialog.Builder builder;
AlertDialog alertDialog;

LayoutInflater inflater = (LayoutInflater)ActivityName.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_layout,(ViewGroup)findViewById(R.id.layout_root));

                builder = new AlertDialog.Builder(getParent());
                builder.setView(layout);
                alertDialog = builder.create();
                alertDialog.show();
Run Code Online (Sandbox Code Playgroud)

问题是弹出窗口被默认的Dialog背景包围,该背景具有自己的标题空白空间(因为标题未设置).我该如何删除它.我试过通过ContextThemeWrapper类似的 定制风格builder = new AlertDialog.Builder(new ContextThemeWrapper(getParent(), R.style.CustomDialogTheme));

但它不起作用.我怎么做?!!!提前致谢.自定义样式xml如下:

<style name="CustomDialogTheme" parent="android:style/Theme.Dialog.Alert">
            <item name="android:windowIsFloating">false</item>
            <item name="android:windowNoTitle">true</item>
        </style>
Run Code Online (Sandbox Code Playgroud)

这是模拟器上的输出

android android-alertdialog

6
推荐指数
2
解决办法
2万
查看次数

MarginLayoutParams.setMargins()不起作用?

事情就是这样:我想以编程方式添加一些图像.图像应当必须具有topMargin5dip除了第一图像,在一个LinearLayout具有一个vertical orientation方式.在代码段下方:

LinearLayout body = (LinearLayout) findViewById(R.id.body);

    for (int i = 1; i <= 4; i++) {

        ImageView img = new ImageView(this);
        MarginLayoutParams lp = new MarginLayoutParams(-2, -2);

        img.setImageResource(R.drawable.image);
        if (i != 1) {

            lp.setMargins(0, 5, 0, 0);

        }
        img.setLayoutParams(lp);

        body.addView(img);
        body.requestLayout();
    }
Run Code Online (Sandbox Code Playgroud)

通过运行程序,我可以看到4个图像(这里)逐个垂直对齐,但没有topMargin(如代码中所示5dip).bodyidLinearLayout.这是以下XML部分:

<LinearLayout
            android:id="@+id/body"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#901b0e08"
            android:orientation="vertical"
            android:paddingLeft="6dp"
            android:paddingRight="8dp" >
 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我不知道这里出了什么问题.

谢谢.

android android-custom-view android-layout

3
推荐指数
1
解决办法
7215
查看次数