我有一个函数,当触发时,成功显示一个DialogFragment与以下代码
DialogFragment
DialogFragment dialog;
View dialogView;
Context activityContext;
...
dialog = new DialogFragment(){
@Override public Dialog onCreateDialog(Bundle savedInstanceState) {
dialogView = getActivity().getLayoutInflater().inflate(R.layout.customView, null);
...
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(dialogView);
return builder.create();
}
};
dialog.show(activityContext.getSupportFragmentManager() , "MyDialog");
Run Code Online (Sandbox Code Playgroud)
问题是,在我添加一个带有以下代码的系统警报窗口后,DialogFragment不再显示,但是如果我传递到另一个应用程序,当我的应用程序最小化时,我可以看到DialogFragment,同时它减小了它的大小
系统警报窗口
WindowManager mWindowManager;
WindowManager.LayoutParams params;
...
mWindowManager = (WindowManager)activityContext.getSystemService(Context.WINDOW_SERVICE);
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
}
params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
addView(((LayoutInflater)activityContext.getSystemService("layout_inflater")).inflate(R.layout.floatingBotton, null));
Run Code Online (Sandbox Code Playgroud)
那么......为什么我不能在顶部看到我的对话框(据我所知,对话框正在显示)为什么它只在显示系统警报窗口时发生
我已尝试使用系统警报窗口的其他标志,但我遇到了与我尝试过的问题相同的问题
android android-dialogfragment dialogfragment system-alert-window
我正在尝试将在全屏活动中播放的视频居中,但我在任何布局中放置的任何参数似乎都不起作用
这是我的清单:
<activity
android:name=".VideoActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
Run Code Online (Sandbox Code Playgroud)
我的 video_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="@+id/videoView"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
以及您需要时的活动
public class VideoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_layout);
VideoView videoHolder = new VideoView(this);
setContentView(videoHolder);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/"+ R.raw.video);
videoHolder.setVideoURI(video);
videoHolder.start();
videoHolder.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
jump();
}
});
}
private void jump() {
if(isFinishing())
return;
finish();
pd.dismiss();
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过 FrameLayou、RelativeLayout、LinearLayout
重心居中,layout_gravity …
android ×2