2011-11-23 58 views
0

我想创建一个自定义dialog.i已经创建了一个RES /价值/ action.xml,2个按钮

<?xml version="1.0" encoding="utf-8"?> 
<resources> 

    <style name="Theme.RCAlertDialog" parent="android:style/Theme.Dialog"> 

     <item name="android:windowBackground">@drawable/quick_action2</item> 

    </style> 
</resources> 

使用IM绘制自定义对话框是这样的:

enter image description here

我想在我的图形中有两个按钮,它们的两个宽度的总和就是红框的宽度。我该怎么做? 这是我现在使用的代码,但结果正在从纵向模式变为横向模式。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="30px" 
     android:layout_marginTop="21px" 
     android:layout_weight="1" 
     android:background="@drawable/fav2" /> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_marginRight="30px" 
     android:layout_marginTop="21px" 
     android:layout_weight="1" 
     android:background="@drawable/eat2" /> 

</LinearLayout> 

是否有这样做的权利什么好的办法感谢

回答

2

检查dawables的大小?:@绘制/ fav2和@绘制/ eat2。不要给ImageButton作为背景,而是将其设置为源(src)。

+0

@kgr,完全是+1 ..我错过了 –