视图未在Android 5.1中呈现

时间:2016-10-21 01:42:59

标签: android

人们我有一个奇怪的问题渲染布局,在使用6.0的genymotion模拟器上测试时工作正常,但是如果我切换到Android 5.1并且没有显示布局,那么当我在运行6.0的设备上直接测试应用程序时也是如此。 1也没有显示。

Api23 Api22

布局代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">





    <LinearLayout
        android:orientation="vertical"
        android:layout_below="@+id/toolbar_info"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="1"
        android:layout_weight="0.9">


            android:scaleType="centerCrop" />-->

        <com.daimajia.slider.library.SliderLayout
            android:id="@+id/product_detail_img_slider"
            android:layout_width="match_parent"
            android:layout_height="170dp"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="wrap_content"
            android:id="@+id/LL_prod_detail_main">




       <LinearLayout
           android:orientation="horizontal"
           android:layout_width="match_parent"
           android:id="@+id/LL_product_Value"
           android:layout_height="wrap_content"
           android:layout_marginTop="15dp"
           android:layout_marginLeft="15dp"
           android:layout_marginRight="15dp">



           <TextView
               android:layout_width="wrap_content"
               android:text="Preço:"
               android:layout_height="wrap_content"
               android:layout_marginTop="2dp"
               android:layout_marginRight="15dp" />

           <TextView
               android:layout_width="match_parent"
               android:id="@+id/txtProductValue"
               android:hint="Product Valor"
               android:layout_height="match_parent"
               android:layout_marginTop="2dp"
               android:gravity="right" />
       </LinearLayout>


            <View
                android:layout_width="fill_parent"
                android:layout_marginTop="10dp"
                android:layout_height="5dp"
                android:background="#c0c0c0"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp" />


        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:id="@+id/LL_product_address"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp">



            <TextView
                android:layout_width="wrap_content"
                android:text="Endereço:"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:layout_marginRight="15dp" />



            <TextView
                android:layout_width="match_parent"
                android:id="@+id/txtProductAdd"
                android:gravity="right"
                android:hint="Product Endereço"
                android:layout_height="match_parent"
                android:layout_marginTop="2dp" />
        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:id="@+id/LL_product_city"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp">



            <TextView
                android:layout_width="wrap_content"
                android:text="Cidade:"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:layout_marginRight="15dp" />


            <TextView
                android:layout_width="match_parent"
                android:id="@+id/txtProductCity"
                android:gravity="right"
                android:hint="Product Cidade"
                android:layout_height="match_parent"
                android:layout_marginTop="2dp" />
        </LinearLayout>


            <View
                android:layout_width="fill_parent"
                android:layout_marginTop="10dp"
                android:layout_height="5dp"
                android:background="#c0c0c0"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp" />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:id="@+id/LL_product_tipo_imovel"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp">


            <TextView
                android:layout_width="wrap_content"
                android:text="Tipo de Imovel:"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:layout_marginRight="15dp" />


            <TextView
                android:layout_width="match_parent"
                android:id="@+id/txtProductType"
                android:gravity="right"
                android:hint="Product Tipo"
                android:layout_height="match_parent"
                android:layout_marginTop="2dp" />
        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:id="@+id/LL_product_info"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="15dp"
            android:weightSum="1"
            android:layout_marginRight="15dp">



                <LinearLayout
                    android:layout_width="wrap_content"
                    android:orientation="horizontal"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:id="@+id/LL_suites">



                    <TextView
                        android:layout_width="wrap_content"
                        android:text="Quartos:"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="2dp"
                        android:layout_marginRight="15dp" />


                        <TextView
                            android:layout_width="match_parent"
                            android:id="@+id/txtProductRooms"
                            android:hint="1"
                            android:layout_height="match_parent"
                            android:layout_marginTop="2dp" />
                </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:orientation="horizontal"
                android:layout_height="wrap_content"
                android:layout_weight="0.3"
                android:id="@+id/LL_baths">

                <TextView
                    android:layout_width="wrap_content"
                    android:text="Banheiros:"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:layout_marginRight="15dp" />

                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:id="@+id/txtProductBath"
                    android:hint="2"
                    android:layout_marginTop="2dp" />

             </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:orientation="horizontal"
                android:layout_height="wrap_content"
                android:layout_weight="0.3"
                android:id="@+id/LL_garage">


                <TextView
                    android:layout_width="wrap_content"
                    android:text="Garagem:"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:layout_marginRight="10dp" />


                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:id="@+id/txtProductGarage"
                    android:hint="3"
                    android:layout_marginTop="2dp"
                    android:gravity="right" />

                </LinearLayout>

            </LinearLayout>







        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:id="@+id/LL_product_area"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp">



            <TextView
                android:layout_width="wrap_content"
                android:text="Area:"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:layout_marginRight="15dp" />


            <TextView
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:id="@+id/txtProductArea"
                android:gravity="right"
                android:hint="Product Area"
                android:layout_marginTop="2dp" />
        </LinearLayout>

            <View
                android:layout_width="fill_parent"
                android:layout_marginTop="10dp"
                android:layout_height="5dp"
                android:background="#c0c0c0"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp" />


            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:id="@+id/LL_product_codigoSeller"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp">



                <TextView
                    android:layout_width="wrap_content"
                    android:text="Nome do Anunciante:"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:layout_marginRight="15dp" />

                    <TextView
                        android:layout_height="wrap_content"
                        android:layout_width="match_parent"
                        android:gravity="right"
                        android:id="@+id/txtProductSeller"
                        android:hint="Product Vendedor"
                        android:layout_marginTop="2dp" />
             </LinearLayout>






        </LinearLayout>




    </LinearLayout>



    <FrameLayout
        android:layout_width="match_parent"
        android:layout_gravity="bottom"
        android:layout_height="wrap_content">

    <com.getbase.floatingactionbutton.FloatingActionsMenu
        android:id="@+id/fabmenu_info_multiple_actions"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        fab:fab_labelStyle="@style/menu_labels_style"
        android:gravity="right"
        app:fab_addButtonColorNormal="@color/colorPrimary"
        app:fab_addButtonColorPressed="@color/colorPrimaryDark"
        app:fab_addButtonPlusIconColor="@color/colorAccent"
        android:layout_marginBottom="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginEnd="16dp">

    </com.getbase.floatingactionbutton.FloatingActionsMenu>

    </FrameLayout>






</LinearLayout>

课堂上的代码

 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


    View vg= inflater.inflate(R.layout.tab_fragment_info, container, false);
    //Toolbar toolbar = (Toolbar) vg.findViewById(R.id.toolbar_info);
    //Get Bundle from Fragment
    bundle=getArguments();
    try {prodDetail=new JSONObject(bundle.get("ARGS").toString());}catch (JSONException ex){};
    session=new UserSessionManager(getContext());

    mOnProductSelectedDataTabs=(OnProductSelectedDataTabs) this;

    mImageSlider=(SliderLayout) vg.findViewById(R.id.product_detail_img_slider);

    HashMap<String, String> url_maps = new HashMap<String, String>();

    try {

        for (int i=0;i<prodDetail.getJSONArray("imagesList").length();i++)
        {
            //String image_desc=prodDetail.getJSONObject("d").getJSONArray("IMAGES").getJSONObject(i).getString("Description");
            String image_desc=prodDetail.getJSONArray("imagesList").getJSONObject(i).getString("ImageDescription");
            String image_path=prodDetail.getJSONArray("imagesList").getJSONObject(i).getString("ImageLocation");
            image_path=getResources().getString(R.string.pm_public_ip_address)+image_path;
            //String image_path=prodDetail.getJSONObject("d").getJSONArray("IMAGES").getJSONObject(i).getString("PicturePath");
            url_maps.put(image_desc, image_path);

        }


       /* url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
        url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
        url_maps.put("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg");*/

    }catch (Exception ex)
    {

    }

    /*HashMap<String,Integer> file_maps = new HashMap<String, Integer>();
    file_maps.put("Hannibal",R.drawable.hannibal);
    file_maps.put("Big Bang Theory",R.drawable.bigbang);
    file_maps.put("House of Cards",R.drawable.house);
    file_maps.put("Game of Thrones", R.drawable.game_of_thrones);*/

    for(String name : url_maps.keySet())
    {
        TextSliderView textSliderView = new TextSliderView(getContext());
        // initialize a SliderLayout
        textSliderView
                .description(name)
                .image(url_maps.get(name))
                .setScaleType(BaseSliderView.ScaleType.Fit)
                .setOnSliderClickListener(this);

        //add your extra information
        textSliderView.bundle(new Bundle());
        textSliderView.getBundle()
                .putString("extra",name);

        mImageSlider.addSlider(textSliderView);
    }

    mImageSlider.setPresetTransformer(SliderLayout.Transformer.Accordion);
    mImageSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
    mImageSlider.setCustomAnimation(new DescriptionAnimation());
    mImageSlider.setDuration(4000);


    txtProductValue=(TextView) vg.findViewById(R.id.txtProductValue);
    txtProductAddress=(TextView) vg.findViewById(R.id.txtProductAdd);
    txtProductCity=(TextView) vg.findViewById(R.id.txtProductCity);
    txtProductType=(TextView) vg.findViewById(R.id.txtProductType);
    txtProductRooms=(TextView) vg.findViewById(R.id.txtProductRooms);
    txtProductBaths=(TextView) vg.findViewById(R.id.txtProductBath);
    txtProductGarage=(TextView) vg.findViewById(R.id.txtProductGarage);
    txtProductArea=(TextView) vg.findViewById(R.id.txtProductArea);
    txtProductSeller=(TextView) vg.findViewById(R.id.txtProductSeller);



    //Setting up Floating Menu

    FloatingActionsMenu fabMenu=(FloatingActionsMenu) vg.findViewById(R.id.fabmenu_info_multiple_actions);
    setButtonsForFabMenu(fabMenu);

    return vg;
}

1 个答案:

答案 0 :(得分:0)

最初我使用的是协调器布局,然后我改为LinearLayout并且问题已经开始,所以我将其更改回协调器布局并且工作正常。

感谢,