1) package com.example.manisha.myapplication;
import android.app.Activity; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.Window; /** * Created by Manisha on 7/29/2017. */ public class NewActivity extends Activity { protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);super.onCreate(savedInstanceState); DisplayMetrics metrics = getResources().getDisplayMetrics(); int screenWidth = (int) (metrics.widthPixels * 0.90); int screenHeight = (int) (metrics.heightPixels * 0.80); setContentView(R.layout.new_activity); getWindow().setLayout(screenWidth, screenHeight); // getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); } }
in manifest
<activity android:name=".NewActivity" android:theme="@android:style/Theme.Dialog"> </activity>