If I have defined a Activity:
public class DialogActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(dialog_activity.xml);
}
}
I would like to display the above activity like a dialog, so in the AndroidManifest.xml file, I declare this activity like below:
<activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"/>
Everything is fine at this point, my DialogActivity
showed as a dialog.
The problem is How to customize the width and height of the DialogActivity
to make it more like a small dialog? (Currently it occupies most of the screen by default)
----------------------------Update-----------------------
I defined a custom theme like below:
<style name="myDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:width">100dip</item>
<item name="android:height">100dip</item>
</style>
Then, declare the DialogActivity
in AndroidManifest.xml as.
<activity android:name=".DialogActivity" android:theme="@style/myDialog"/>
My DialogActivity
now even occupies the whole screen:( . The width and height definition:
<item name="android:width">100dip</item>
in the theme do not take any effect, why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…