If I have defined a Activity:
public class DialogActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
supe
You can set the layout height and width in layout xml file
You can even mention the values like "240px" for android:layout_width/android:layout_height
I had similar problem, I used following theme for my activity
android:theme="@style/Base.Theme.AppCompat.Light.Dialog"
The following code fixed my problem
setContentView(R.layout.activity_layout);
getWindow().setLayout(width(pixels),height(pixels));
I finally figured out one way to customize the size of my DialogActivity
.
That's inside the onCreate()
method of DialogActivity
, add the following code:
WindowManager.LayoutParams params = getWindow().getAttributes();
params.x = -20;
params.height = 100;
params.width = 550;
params.y = -10;
this.getWindow().setAttributes(params);
There's a one-line code without hassling with the LayoutParams that is
getWindow().setLayout((int)(width*.8),(int)(height*.25));
This is what I've used before in one of my projects and now searching for, but found it in the same project.
You can just change params of window in your acctivity like:
override fun onStart() {
super.onStart()
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}