android–Spinner在选择项目后向下移动布局

android–Spinner在选择项目后向下移动布局,第1张

概述我有一个奇怪的问题.我在布局中添加了一个微调器.当我在微调器中选择一个项目时,微调器在布局中向下移动,导致页面中的垂直滚动.我不希望发生这种情况,因为这会导致我的页面上的按钮在滚动之前显示在屏幕上较少.<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:andr

我有一个奇怪的问题.我在布局中添加了一个微调器.当我在微调器中选择一个项目时,微调器在布局中向下移动,导致页面中的垂直滚动.我不希望发生这种情况,因为这会导致我的页面上的按钮在滚动之前显示在屏幕上较少.

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:background="@androID:color/white"androID:orIEntation="vertical"androID:paddingBottom="8dp"androID:paddingleft="20dp"androID:paddingRight="20dp" ><linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:orIEntation="horizontal"    androID:paddingBottom="10dp"    androID:paddingtop="20dp" >    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:orIEntation="horizontal" >        <com.androID.volley.toolBox.NetworkImageVIEw            androID:ID="@+ID/ID_gwp_configuration_productimage"            androID:layout_wIDth="@dimen/product_collections_image_wIDth"            androID:layout_height="@dimen/product_collections_image_height"            androID:scaleType="fitXY" />        <linearLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:orIEntation="vertical"            androID:paddingleft="10dp" >            <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw                androID:ID="@+ID/ID_gwp_configuration_TitleTxt"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="10dp"                androID:ellipsize="end"                androID:linespacingExtra="8dp"                androID:maxlines="3"                androID:paddingBottom="4dp"                androID:singleline="false"                androID:text="@string/pdp_Title"                androID:textcolor="@androID:color/black"                androID:textSize="12sp" />            <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw                androID:ID="@+ID/ID_gwp_configuration_salePriceTxt"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:paddingBottom="5dp"                androID:text="@string/pdp_sale_price"                androID:textcolor="@color/pdp_red_sale_price"                androID:textSize="18sp"                androID:textStyle="bold" />            <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw                androID:ID="@+ID/ID_gwp_configuration_regularPriceTxt"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:paddingBottom="10dp"                androID:text="@string/pdp_regular_price"                androID:textcolor="@color/pdp_grey_original_price"                androID:textSize="12sp" />            <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw                androID:ID="@+ID/ID_gwp_configuration_skuCodeTxt"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:paddingBottom="10dp"                androID:text="@string/pdp_regular_price"                androID:textcolor="@color/pdp_grey_original_price"                androID:textSize="12sp" />        </linearLayout>    </linearLayout></linearLayout><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw    androID:ID="@+ID/ID_gwp_configuration_offerTxt"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="10dp"    androID:maxlines="2"    androID:paddingBottom="20dp"    androID:textcolor="@color/pdp_green_offer"    androID:textSize="12sp"    androID:visibility="gone" /><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw    androID:ID="@+ID/ID_gwp_configuration_short_description"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:ellipsize="end"    androID:linespacingExtra="8dp"    androID:maxlines="2"    androID:text="Description text"    androID:textSize="12sp" /><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw    androID:ID="@+ID/ID_gwp_configuration_show_more"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:gravity="right"    androID:text="@string/show_more"    androID:textcolor="@androID:color/holo_blue_bright"    androID:textSize="12sp" /><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw    androID:ID="@+ID/ID_gwp_configuration_long_descTxt"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:linespacingExtra="8dp"    androID:text="Description text"    androID:textSize="12sp"    androID:visibility="gone" /><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw    androID:ID="@+ID/ID_gwp_configuration_show_less"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:gravity="right"    androID:text="@string/show_less"    androID:textcolor="@androID:color/holo_blue_bright"    androID:textSize="12sp"    androID:visibility="gone" /><include    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    layout="@layout/product_details_swatch_images" /><linearLayout    androID:ID="@+ID/ID_gwp_configuration_swatchShowLessLayout"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:orIEntation="vertical"    androID:visibility="gone" >    <VIEw        androID:layout_wIDth="match_parent"        androID:layout_height="1dp"        androID:background="@drawable/product_detail_black_divIDer" />    <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw        androID:ID="@+ID/ID_gwp_configuration_swatchShowLesstxt"        androID:layout_wIDth="match_parent"        androID:layout_height="25dp"        androID:background="@androID:color/white"        androID:gravity="center_horizontal|center_vertical"        androID:text="@string/pdp_show_fewer_colors"        androID:textcolor="@androID:color/black"        androID:textSize="12sp"        androID:textStyle="bold" /></linearLayout><linearLayout    androID:ID="@+ID/ID_gwp_configuration_sizeLayout"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:orIEntation="vertical"    androID:padding="4dp"    androID:visibility="gone" >    <Spinner        androID:ID="@+ID/ID_gwp_configuration_sizeSpinner"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:paddingtop="16dp" />    <linearLayout        androID:ID="@+ID/ID_gwp_configuration_sizeGuIDeLayout"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:orIEntation="vertical" >        <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw            androID:ID="@+ID/ID_gwp_configuration_siZenotSureTxt"                        androID:layout_wIDth="match_parent"            androID:layout_height="match_parent"            androID:layout_gravity="center_vertical"            androID:text="@string/pdp_not_sure_about_size"            androID:textcolor="@androID:color/black"            androID:textSize="12sp"            androID:textStyle="bold" />        <linearLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:orIEntation="horizontal" >            <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw                androID:ID="@+ID/ID_gwp_configuration_sizeCheckOutTxt"                androID:layout_wIDth="wrap_content"                androID:layout_height="match_parent"                androID:layout_gravity="center_vertical"                androID:text="@string/pdp_check_out_guIDe"                androID:textcolor="@androID:color/black"                androID:textSize="12sp" />            <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw                androID:ID="@+ID/ID_gwp_configuration_sizeGuIDe"                androID:layout_wIDth="wrap_content"                androID:layout_height="match_parent"                androID:layout_gravity="center_vertical"                androID:textcolor="@androID:color/black"                androID:textSize="12sp" />        </linearLayout>    </linearLayout></linearLayout><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBookTextVIEw    androID:ID="@+ID/ID_gwp_configuration_quantityTxt"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:paddingleft="4dp"    androID:paddingtop="12dp"    androID:text="@string/pdp_quantity"    androID:textcolor="@androID:color/black"    androID:textSize="12sp"    androID:visibility="gone" /><linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:orIEntation="horizontal"    androID:padding="4dp" >    <button        androID:ID="@+ID/ID_gwp_configuration_qtyDownBtn"        androID:layout_wIDth="40dp"        androID:layout_height="40dp"        androID:background="@drawable/product_detail_black_border"        androID:text="@string/pdp_qty_minus"        androID:textcolor="@androID:color/black"        androID:textSize="20sp"        androID:visibility="gone" />    <EditText        androID:ID="@+ID/ID_gwp_configuration_qtyValue"        androID:layout_wIDth="40dp"        androID:layout_height="40dp"        androID:background="@drawable/product_detail_black_border"        androID:gravity="center"        androID:inputType="number"        androID:text="1"        androID:textcolor="@androID:color/black"        androID:textSize="20sp"        androID:visibility="gone" />    <button        androID:ID="@+ID/ID_gwp_configuration_qtyUpBtn"        androID:layout_wIDth="40dp"        androID:layout_height="40dp"        androID:background="@drawable/product_detail_black_border"        androID:text="@string/pdp_qty_plus"        androID:textcolor="@androID:color/black"        androID:textSize="20sp"        androID:visibility="gone" />    <com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldbutton        androID:ID="@+ID/ID_gwp_configuration_addGiftToBagBtn"        androID:layout_wIDth="match_parent"        androID:layout_height="40dp"        androID:layout_gravity="center"        androID:background="@color/pdp_add_to_bag_disable"        androID:text="@string/gwp_add_gift_to_bag"        androID:textcolor="@androID:color/white"        androID:textSize="12sp" /></linearLayout><com.kohls.mcommerce.opal.framework.vIEw.component.vIEws.GothamBoldTextVIEw    androID:ID="@+ID/ID_gwp_configuration_removeGift"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="10dp"    androID:gravity="center"    androID:paddingBottom="4dp"    androID:text="@string/pdp_remove_gift"    androID:textcolor="@androID:color/black"    androID:textSize="12sp"    androID:visibility="gone" />

 

这里我在代码中使用微调器

/** * Set spinner to display size of the mProduct. */private voID setProductSizeSpinner() {    if (mProduct != null) {        List<String> sizeList = new ArrayList<String>();        if (mProduct.getSKUS() != null) {            ArrayList<String> sizeListSet = null;            Pricecolor pricecolor = new Pricecolor();            if (mSelectedcolor == null) {                if (!mcolorToSizeMap.isEmpty()) {                    Iterator<Entry<Pricecolor, ArrayList<String>>> enterIEs = mcolorToSizeMap.entrIEs();                    if (enterIEs.hasNext()) {                        Entry<Pricecolor, ArrayList<String>> entry = enterIEs.next();                        pricecolor = entry.getKey();                        if (entry.getKey() != null) {                            mSelectedcolor = entry.getKey().color;                        } else {                            mSelectedcolor = new String();                        }                        sizeListSet = entry.getValue();                        mIscolorrequired = true;                        mSwatchcolornameLayout.setVisibility(VIEw.VISIBLE);                        mTextSwatchcolorname.setText(" " + mSelectedcolor);                    }                }            } else {                com.kohls.mcommerce.opal.common.util.Logger.deBUG("ProductDetails",                        "Price : " + mSelectedPrice);                if (mSelectedPrice == null || mSelectedPrice.equalsIgnoreCase("")) {                    pricecolor.price = getSKUPrice(mSku);                } else {                    pricecolor.price = mSelectedPrice;                }                pricecolor.color = mSelectedcolor;                if (mSwatchImagesList != null && !mSwatchImagesList.isEmpty()) {                    sizeListSet = mcolorToSizeMap.getValue(pricecolor);                } else if (!mcolorToSizeMap.isEmpty()) {                    Collection<ArrayList<String>> allSizesList = mcolorToSizeMap.getAllValues();                    sizeListSet = new ArrayList<String>();                    for (ArrayList<String> newSizesList : allSizesList) {                        sizeListSet.addAll(newSizesList);                    }                }            }            if (mCrossedcolorsIDs != null && !mCrossedcolorsIDs.isEmpty()) {                clearCrossedSwatchImages();            }            if (sizeListSet != null) {                sizeList = removeOutofStockSizes(sizeListSet, pricecolor);            }            if (sizeList != null && sizeList.size() > 0) {                mIsSizerequired = true;                sizeList.add(0, mContext.getString(R.string.pdp_select_size));                mSpinnerProductSizeLayout.setVisibility(VIEw.VISIBLE);                mSpinnerProductSize.setVisibility(VIEw.VISIBLE);                dropDownAdapterSize = new ArrayAdapter<String>(mContext,                        R.layout.spinner_text_vIEw,                        sizeList) {                    @OverrIDe                    public VIEw                            getDropDownVIEw(int position, VIEw convertVIEw, VIEwGroup parent) {                        VIEw vIEw = null;                        TextVIEw textSize = new TextVIEw(getContext());                        if (position == 0) {                            textSize.setHeight(0);                            textSize.setVisibility(VIEw.GONE);                            vIEw = textSize;                        } else {                            // Pass convertVIEw as null to prevent                            // reuse of special case vIEws                            vIEw = super.getDropDownVIEw(position, null, parent);                        }                        return vIEw;                    }                };                mSpinnerProductSize.setAdapter(dropDownAdapterSize);                // Select last selected value of size.                if (mSelectedSize != null && mSkuMap.size() > 1) {                    int spinnerposition = dropDownAdapterSize.getposition(mSelectedSize);                    if (spinnerposition == -1) {                        mSpinnerProductSize.setSelection(0);                        mIsSizerequired = false;                        mSelectedSize = null;                        setbuttonState(false);                    } else {                        mSpinnerProductSize.setSelection(spinnerposition);                    }                }                mSpinnerProductSize.setonItemSelectedListener(mSizeSpinnerItemSelectedListener);            } else {                mIsSizerequired = false;                mSpinnerProductSize.setSelection(0);                mSpinnerProductSize.setVisibility(VIEw.INVISIBLE);            }        }    }}

https://www.dropbox.com/s/50xw0szs96c8ql0/Screenshot_2015-09-05-14-40-17.png?dl=0

https://www.dropbox.com/s/e8x066r9e4iz3mu/Screenshot_2015-09-05-14-42-48.png?dl=0

正如您在上面的屏幕截图中看到的那样,我指的是“添加礼物到包”按钮被隐藏.

解决方法:

你只需要指定微调器的高度,

总结

以上是内存溢出为你收集整理的android – Spinner在选择项目后向下移动布局全部内容,希望文章能够帮你解决android – Spinner在选择项目后向下移动布局所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1117229.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存