Android对话框破坏了我的主要布局

时间:2012-10-23 09:12:48

标签: android layout button dialog

情境: 我有一个主要的布局运行。 点击“帮助”按钮后会出现一个对话框 我解雇了帮助对话框 主屏幕有2个按钮,现在已经坏了(图形错误)

我附上了屏幕截图,其中的按钮现在还没有完成(坏按钮是“搜索联系人”和“通话”)。

显然问题是,如何在不影响主屏幕图形的情况下解除对话框? Screen with bad buttons after dialog disappears

主屏幕布局

<LinearLayout 
    xmlns:android           = "http://schemas.android.com/apk/res/android"
    android:layout_width    = "fill_parent"
    android:layout_height   = "fill_parent"
    android:paddingLeft     = "@dimen/general_logo_padding"
    android:paddingRight    = "@dimen/general_logo_padding"
    android:orientation     = "vertical"
    android:background      = "@drawable/login_background" >


        <!-- Logo -->
        <ImageView    
            android:id                  = "@+id/imgLogo"
            android:src                 = "@drawable/emobile_logo10"
            android:contentDescription  = "@string/login_imgdescriptor_logo"
            android:layout_width        = "fill_parent"
            android:layout_height       = "wrap_content"
            android:layout_marginTop    = "@dimen/callback_logo_margin"
            android:scaleType           = "fitStart" 
            android:layout_weight       = "0.1"/>


        <!-- Callback Fields -->
        <!-- Your Number -->
        <LinearLayout 
            xmlns:android               = "http://schemas.android.com/apk/res/android"
            android:layout_width        = "fill_parent"
            android:layout_height       = "wrap_content"
            android:orientation         = "horizontal" 
            android:layout_marginTop    = "@dimen/callback_yournumber_margin" 
            android:layout_weight       = "0.2">

            <TextView
                android:id              = "@+id/tvCBYournumber"
                android:layout_width    = "fill_parent"
                android:layout_height   = "wrap_content"
                android:text            = "@string/callback_btn_yournumber"
                android:textAppearance  = "?android:attr/textAppearanceMedium"
                android:textSize        = "@dimen/login_fields_text_size" 
                android:textColor       = "#F26A05" 
                android:layout_weight   = "6"/>

            <EditText 
                android:id                  = "@+id/etCBYourNumber"
                android:layout_height       = "wrap_content"
                android:layout_width        = "fill_parent"
                android:inputType           = "number"
                android:ellipsize           = "end"
                android:singleLine          = "true"
                android:minHeight           = "@dimen/edittext_min_height"
                android:background          = "@drawable/edittext_round_corners"        
                android:gravity             = "center"
                android:textAppearance      = "?android:attr/textAppearanceMedium"
                android:textSize            = "@dimen/login_fields_text_size" 
                android:layout_weight       = "4" />
        </LinearLayout>

        <!-- Connect To -->
        <LinearLayout 
            xmlns:android               = "http://schemas.android.com/apk/res/android"
            android:layout_width        = "fill_parent"
            android:layout_height       = "wrap_content"
            android:layout_marginTop    = "@dimen/callback_connectto_margin"
            android:orientation         = "horizontal" 
            android:layout_weight       = "0.2">

            <TextView
                android:id              = "@+id/tvCBConnectto"
                android:layout_width    = "fill_parent"
                android:layout_height   = "wrap_content"
                android:text            = "@string/callback_btn_connectto"
                android:textAppearance  = "?android:attr/textAppearanceMedium"
                android:textSize        = "@dimen/login_fields_text_size" 
                android:textColor       = "#F26A05" 
                android:layout_weight   = "6"/>

            <EditText 
                android:id                  = "@+id/etCBConnectTo"
                android:layout_height       = "wrap_content"
                android:layout_width        = "fill_parent"
                android:inputType           = "number"
                android:ellipsize           = "end"
                android:singleLine          = "true"
                android:minHeight           = "@dimen/edittext_min_height"
                android:background          = "@drawable/edittext_round_corners"        
                android:gravity             = "center"
                android:textAppearance      = "?android:attr/textAppearanceMedium"
                android:textSize            = "@dimen/login_fields_text_size" 
                android:layout_weight       = "4"/>
        </LinearLayout>

        <!-- Line of Buttons -->
        <LinearLayout 
            xmlns:android               = "http://schemas.android.com/apk/res/android"
            android:layout_width        = "fill_parent"
            android:layout_height       = "wrap_content"
            android:orientation         = "horizontal" 
            android:layout_marginTop    = "@dimen/callback_button_margin" 
            android:minHeight           = "@dimen/callback_button_height"
            android:layout_weight       = "0.1">

            <Button
                android:id                  = "@+id/btnCBSearchContacts"
                android:layout_width        = "fill_parent"
                android:layout_height       = "fill_parent"
                android:text                = "@string/callback_btn_searchcontacts" 
                android:textSize            = "@dimen/login_fields_text_size" 
                android:drawableLeft        = "@android:drawable/ic_menu_my_calendar"
                android:layout_weight       = "1" />

            <Button
                android:id                  = "@+id/btnCBCall"
                android:layout_width        = "fill_parent"
                android:layout_height       = "fill_parent"
                android:text                = "@string/callback_btn_call" 
                android:layout_marginLeft   = "@dimen/callback_button_margin_betweenbuttons"
                android:textSize            = "@dimen/login_fields_text_size" 
                android:drawableLeft        = "@android:drawable/ic_menu_call"
                android:layout_weight       = "1" />

        </LinearLayout>                        

        <RelativeLayout 
            xmlns:android               = "http://schemas.android.com/apk/res/android"
            android:layout_width        = "fill_parent"
            android:layout_height       = "fill_parent" 
            android:layout_weight       = "3">

            <Button
                android:id                      = "@+id/btnCBHelp"
                android:layout_width            = "wrap_content"
                android:layout_height           = "wrap_content"
                android:padding                 = "@dimen/callback_button_help_padding"
                android:text                    = "@string/callback_btn_help" 
                android:layout_centerInParent   = "true"
                android:textSize                = "@dimen/login_fields_text_size" 
                android:drawableLeft            = "@android:drawable/ic_menu_help" />
        </RelativeLayout>

</LinearLayout>

2 个答案:

答案 0 :(得分:0)

使用AlertDialog弹出新布局,还可以看到android documention

感谢。

答案 1 :(得分:0)

好吧,我发现了问题。

似乎问题在于我用来创建按钮的库,它处于非常早期的Beta阶段,并且由于某种原因导致了这个问题。

我正在使用Pixate库

我现在已经调整了代码以使用LayoutInflater(Parth Doshi的想法 - 谢谢),而不是扩展Dialog我现在使用的是Alert对话框(Md Abdul Gafur),使用这两种方法减少了问题但是没有解决它

谢谢大家, Chaiavi。