Blame view
app/src/main/java/com/dinhcv/lifelogpedometer/activity/DialogBase.java
1.21 KB
|
7f095a929
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package com.dinhcv.lifelogpedometer.activity;
import android.content.Context;
import android.support.v7.app.AppCompatDialog;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.TextView;
import com.dinhcv.lifelogpedometer.utils.Debug;
public class DialogBase extends AppCompatDialog {
public DialogBase(Context context) {
super(context);
}
public DialogBase(Context context, int style) {
super(context, style);
}
@Override
protected void onStart() {
super.onStart();
// In order to not be too narrow, set the window size based on the screen resolution:
final int screenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
final int newScreenWidth = screenWidth * 100 / 100;
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.width = Math.max(layout.width, newScreenWidth );
TextView textView = (TextView) findViewById(android.R.id.title);
if(textView != null) {
Debug.normal("Set title dialog ----------------------------------");
textView.setSingleLine(false);
textView.setGravity(Gravity.CENTER);
}
}
}
|