Reputation: 61
I'm a new freshman from china. I want to make a android dialog activity at the top of screen.
I have setted the style as this:
<resources>
<style name="Theme.InputAddressDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:gravity">top</item>
<item name="android:layout_gravity">top</item>
</style>
The dialog activity appears at the center of vertical but not the top. Anybody can help me? Thanks in advance!
Upvotes: 1
Views: 3919
Reputation: 61
I solve this problem as following.
LayoutParams lp = this.getWindow().getAttributes();
lp.gravity = Gravity.TOP | Gravity.LEFT;
lp.dimAmount = 0;
lp.flags = LayoutParams.FLAG_LAYOUT_NO_LIMITS
| LayoutParams.FLAG_NOT_TOUCH_MODAL;
LayoutInflater inflater = getLayoutInflater();
LinearLayout ll = (LinearLayout) inflater.inflate(
R.layout.input_address, null);
setContentView(ll, lp);
Upvotes: 4