我正在尝试创建一个配置有几个文本视图、一个编辑文本、滚动视图和一个“确定”按钮的自定义对话框。由于某些原因,我无法正确对齐对话框中的“确定”按钮。
我创建对话框的代码如下:
mLineupDialog=new Dialog(context,R.style.CustomDialogTheme);
mLineupDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
View view = LayoutInflater.from(context).inflate(R.layout.custom_dialog, null, false);
rg = (RadioGroup) view.findViewById(R.id.radiogroup);
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(
RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
for (int i = 0; i < lobjs.length; i++){
rb = new RadioButton(context);
rb.setText(lobjs[i].carrierName);
rb.setId(i);
// rb.setTextColor
rg.addView(rb, layoutParams);
}
zipEntry.setText(mZipCode);
mPrefs.edit().putString(sharedZipEntry, mZipCode).commit();
}
mLineupDialog.setContentView(view);
Button Ok =(Button)view.findViewById(R.id.lineupdialogButton);
我的布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linlayoutBase"
android:layout_width="@dimen/favorite_dialog_width"
android:layout_height="match_parent"
android:background="@drawable/add_remove_to_favs_question_bottom_bubble"
android:focusableInTouchMode="false"
android:orientation="vertical" >
<TextView
android:id="@+id/lineup_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/favorite_dialog_text_margin_left"
android:layout_marginTop="@dimen/favorite_dialog_text_margin_top"
android:text="@string/sel_lineup"
android:textColor="@color/white_font"
android:textSize="@dimen/fav_alert_text_size"
android:typeface="sans" >
</TextView>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/zipcode_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/favorite_dialog_text_margin_left"
android:text="@string/sel_zipcode"
android:textColor="@color/white_font"
android:textSize="@dimen/fav_alert_text_size"
android:typeface="sans" >
</TextView>
<EditText
android:id="@+id/zipEntry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/white_font"
android:textSize="@dimen/fav_alert_text_size"
android:typeface="sans" >
</EditText>
</LinearLayout>
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/linearMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/favorite_dialog_text_margin_left" >
<RadioGroup
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/favorite_dialog_text_margin_left"
android:orientation="vertical"
android:textColor="@color/white_font"
android:textSize="@dimen/fav_alert_text_size"
android:typeface="sans" >
</RadioGroup>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/lineupdialogButton"
android:layout_width="@dimen/favorite_dialog_button_width"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:gravity="center_horizontal"
android:text="@string/favorite_dialog_button_ok_text"
android:textColor="@xml/info_panel_button_text_watch_selector"
android:textSize="@dimen/favorite_dialog_button_text_size"
android:textStyle="bold"
android:typeface="sans" >
<!-- android:layout_weight="1" -->
</Button>
</LinearLayout>
问题是“确定”按钮只是部分超出了对话框的底部边框。. 任何解决此问题的建议将不胜感激!谢谢!!