微调器未填充其父项

问题描述

| 我在带有“主题”对话框的活动中使用微调框。 我无法让微调框填充父级宽度-始终仅在文本长度内-无论我做什么。这是我的布局定义。
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_height=\"match_parent\"  android:layout_width=\"match_parent\" android:orientation=\"vertical\">
        <LinearLayout android:id=\"@+id/weight_units\"
            android:layout_width=\"match_parent\" android:gravity=\"top|center_vertical|center_horizontal\"
            android:orientation=\"horizontal\" android:layout_marginBottom=\"3dip\" android:layout_marginTop=\"3dip\"  android:layout_height=\"wrap_content\">
            <TextView android:layout_marginRight=\"3dip\" android:id=\"@+id/spinner_lbl\"
                android:text=\"@string/weight_units\"
                android:layout_marginLeft=\"3dip\" android:layout_height=\"wrap_content\"
                android:layout_width=\"match_parent\" android:layout_gravity=\"center_vertical|center_horizontal\"  android:layout_weight=\"1\" ></TextView>
            <Spinner android:id=\"@+id/weight_spinner\" android:layout_height=\"wrap_content\" android:layout_weight=\"1\" android:layout_width=\"match_parent\"></Spinner>
        </LinearLayout>

        <LinearLayout android:orientation=\"vertical\"
            android:paddingTop=\"2dip\" android:paddingBottom=\"2dip\" android:layout_width=\"match_parent\" android:layout_height=\"wrap_content\" android:layout_weight=\"1\">
            <TextView android:layout_width=\"match_parent\"
                android:layout_height=\"wrap_content\" android:layout_marginTop=\"10dip\"
                android:text=\"@string/calc_formula_prompt\" />
            <Spinner android:id=\"@+id/calc_spinner\" android:layout_height=\"wrap_content\" android:prompt=\"@string/calc_formula_prompt\" android:layout_width=\"fill_parent\"/>
        </LinearLayout>
需要明确的是-我确实希望将活动作为对话框打开,并抓住屏幕的大部分内容-但是当我进行横向操作时-微调器不会拉伸到整个父级宽度。 提前致谢     

解决方法

问题在于该视图已膨胀,并用作ViewFlipper中的竞争对象之一。 缺少并引起这种烦人行为的代码是使用正确的LayoutParams在其父布局中添加了脚蹼。
    flipper = new MyViewFlipper(this,gestureDetector);
    lay1.addView(flipper,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
对于不完整的问题,我深表歉意-我不知道这可能与将鳍状肢添加到其父项的方式有关。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...