微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

微调器未填充其父项

如何解决微调器未填充其父项

| 我在带有“主题”对话框的活动中使用微调框。 我无法让微调框填充父级宽度-始终仅在文本长度内-无论我做什么。这是我的布局定义。
<?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));
对于不完整的问题,我深表歉意-我不知道这可能与将鳍状肢添加到其父项的方式有关。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。