Android AlertDialog动态添加组件和padding靠边问题
先上图
?

?
?
AlertDialog有个问题是动态添加组件时,组件会很靠边框,这样很不好看,下面这个方案是解决这个问题
?
?
LayoutInflater mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);View view = mInflater.inflate(R.layout.recordlayout, null);LinearLayout layout = (LinearLayout) view.findViewById(R.id.id_recordlayout);for (int i = 0; i < fieldName.length; i++) {String name = fieldName[i];if ("_id".equals(name))continue;TextView tv = new TextView(getContext());tv.setText(fieldName[i]);EditText edit = new EditText(getContext());layout.addView(tv);layout.addView(edit);}AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());dialog.setTitle(R.string.add_a_record);dialog.setView(view);dialog.setPositiveButton(R.string.ok,new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {}});dialog.setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {}});dialog.show();?
?
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="fill_parent"><LinearLayout android:id="@+id/id_recordlayout"android:layout_width="fill_parent" android:layout_height="fill_parent"android:orientation="vertical" android:padding="10dip"></LinearLayout></ScrollView>
?
?
1 楼 松鼠88 2010-12-05 请问在AlertDialog的每个条目中加个图片改怎么弄啊,楼主? 2 楼 fonter 2010-12-06 松鼠88 写道请问在AlertDialog的每个条目中加个图片改怎么弄啊,楼主?