Reputation: 3990
In my android app I have a custom dialog box. I want to set the height of dialog's Title bar. My style is as follows:
<resources>
<style name="customDialogStyle" parent="android:Theme.Dialog">
<item name="android:background">#04a9ee</item>
<item name="android:height">5dp</item>
</style>
</resources>
But there is no effect of "height" attribute on title bar. So, how can the height of custom dialog's title bar can be changed ?
Upvotes: 3
Views: 6056
Reputation: 6138
This works for me
Your theme:
<resources>
<style name="MyDialog" parent="android:Theme.Holo.Dialog">
.......
</style>
</resources>
Your Custom Dialog Class:
public class CustomDialog extends Dialog
{
public CustomDialog(Context context, int theme) {
super(context, theme);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...........
Resources res = getContext().getResources();
int titleId = res.getIdentifier("title", "id", "android");
View title = findViewById(titleId);
if (title != null) {
title.getLayoutParams().height = 5; // your height
}
}
}
Create dialog and show in your code:
CustomDialog customDialog = new CustomDialog(this, R.style.MyDialog);
customDialog.show();
Upvotes: 2
Reputation: 1985
Yeh I just check, you want to use "android:layout_height"
other heights you can use also like: "android:minHeight"
Upvotes: 2