2017-04-18 4 views
0

を返します。高さを0に設定するか、またはView.Visibility - GONEプロパティを使用して、プログラムでビューを非表示にしようとしています。それはとして機能しますが、それはそのLayoutParamsを取得し、0にその高さを設定することによりINVISIBLEインナービューのレイアウトは、いつも私がlayout_weightに係る引き出しアイテムとビューをレンダリングするDrawerLayout</em><em>の内側のLinearLayout</em><em>を持っているでframeLayout

  • として機能GONEとしてそのVisibiltyを設定することにより

    • をしようとしました

      INVISIBLE

    ParentLayout:mother.xml

    <?xml version="1.0" encoding="utf-8"?> 
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    
    <android.support.v4.widget.DrawerLayout 
        android:id="@+id/activityMotherDrawerLayout" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:fitsSystemWindows="true"> 
    
        <include layout="@layout/activity_mother" /> 
    
        <include layout="@layout/motherdrawer" /> 
    
        </android.support.v4.widget.DrawerLayout> 
    

    レイアウト:motherdrawer.xml

    <?xml version="1.0" encoding="utf-8"?> 
    <com.app.ui.view.ScrimInsetsFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/drawerRootLayout" 
        android:layout_width="@dimen/activity_mother_drawer_width" 
        android:layout_height="match_parent" 
        android:layout_gravity="start" 
        android:background="@color/background_application" 
        android:fitsSystemWindows="false" 
        android:orientation="vertical"> 
    
    <RelativeLayout 
        android:id="@+id/activityMotherDrawerInnerLayout" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical" 
        android:padding="@dimen/activity_mother_drawer_layout_padding"> 
    
        <LinearLayout 
         android:id="@+id/activityMotherDrawerInnerInnerLayout" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:orientation="vertical"> 
    
    
         <LinearLayout 
          android:id="@+id/activityMotherDrawerMyAttendanceLayout" 
          android:layout_width="match_parent" 
          android:layout_height="0dp" 
          android:layout_gravity="center" 
          android:layout_weight="1" 
          android:clickable="true" 
          android:orientation="vertical"> 
    
          <ImageView 
           android:id="@+id/activityMotherDrawerMyAttendanceIv" 
           android:layout_width="match_parent" 
           android:layout_height="0dp" 
           android:layout_centerInParent="true" 
           android:layout_weight="1.5" 
           android:padding="@dimen/activity_mother_drawer_image_padding" 
           android:scaleType="centerInside" 
           android:src="@drawable/ic_drawer_attendance" /> 
    
          <android.support.v7.widget.AppCompatTextView 
           android:layout_width="match_parent" 
           android:layout_height="0dp" 
           android:layout_below="@id/activityMotherDrawerMyAttendanceIv" 
           android:layout_centerHorizontal="true" 
           android:layout_weight="1" 
           android:gravity="top|center" 
           android:text="@string/activity_mother_drawer_attendance" 
           android:textColor="@color/colorGray" 
           android:textSize="@dimen/activity_mother_drawer_text_size" /> 
    
         </LinearLayout> 
    
         <LinearLayout 
          android:id="@+id/activityMotherDrawerDashboardLayout" 
          android:layout_width="match_parent" 
          android:layout_height="0dp" 
          android:layout_gravity="center" 
          android:layout_weight="1" 
          android:clickable="true" 
          android:orientation="vertical"> 
    
          <ImageView 
           android:id="@+id/activityMotherDrawerDashboardIv" 
           android:layout_width="match_parent" 
           android:layout_height="0dp" 
           android:layout_centerInParent="true" 
           android:layout_weight="1.5" 
           android:padding="@dimen/activity_mother_drawer_image_padding" 
           android:scaleType="centerInside" 
           android:src="@drawable/ic_drawer_dashboard" /> 
    
          <android.support.v7.widget.AppCompatTextView 
           android:layout_width="match_parent" 
           android:layout_height="0dp" 
           android:layout_below="@id/activityMotherDrawerDashboardIv" 
           android:layout_centerHorizontal="true" 
           android:layout_weight="1" 
           android:gravity="top|center" 
           android:text="@string/activity_mother_drawer_dashboard" 
           android:textColor="@color/colorGray" 
           android:textSize="@dimen/activity_mother_drawer_text_size" /> 
    
         </LinearLayout> 
    
         <LinearLayout 
          android:id="@+id/activityMotherDrawerSettingsLayout" 
          android:layout_width="match_parent" 
          android:layout_height="0dp" 
          android:layout_gravity="center" 
          android:layout_weight="1" 
          android:clickable="true" 
          android:orientation="vertical"> 
    
          <ImageView 
           android:id="@+id/activityMotherDrawerSettingsIv" 
           android:layout_width="match_parent" 
           android:layout_height="0dp" 
           android:layout_centerInParent="true" 
           android:layout_weight="1.5" 
           android:padding="@dimen/activity_mother_drawer_image_padding" 
           android:scaleType="centerInside" 
           android:src="@drawable/ic_drawer_settings" /> 
    
          <android.support.v7.widget.AppCompatTextView 
           android:layout_width="match_parent" 
           android:layout_height="0dp" 
           android:layout_below="@id/activityMotherDrawerSettingsIv" 
           android:layout_centerHorizontal="true" 
           android:layout_weight="1" 
           android:gravity="top|center" 
           android:text="@string/activity_mother_drawer_setting" 
           android:textColor="@color/colorGray" 
           android:textSize="@dimen/activity_mother_drawer_text_size" /> 
    
         </LinearLayout> 
        </LinearLayout> 
    
        </RelativeLayout> 
    </com.app.ui.view.ScrimInsetsFrameLayout>` 
    

    私はgetLayoutPaを使用してlayoutParamを取得しようとしたときはいつでもRAMは、を返します。FrameLayoutここで、ParentViewはLinearLayoutです。

    Javaの使用:それは代わりに のLinearLayoutまたは、なぜその可視性の変化INVISIBLEの代わりに、GONEへのでframeLayoutを返す理由

    mDashboardLayout = (LinearLayout)mDrawerInnerRootLayout.findViewById(R.id.activityMotherDrawerDashboardLayout); 
    LinearLayout.LayoutParams mParams = (LinearLayout.LayoutParams) mDashboardLayout.getLayoutParams();//returns FrameLayout instead where it should return LinearLayout 
    
    mDashboardLayout.setVisibility(View.GONE); //it acts as INVISIBILITY 
    

    誰も私を啓発することはできますか?

  • 答えて

    0

    表示視認性をGONEまたはINVISIBLEに変更しても、表示は常に表示されません。それはonClickイベントを受け入れます。 SOごとに、私はその見解を完全に取り除きたい。私は以下の方法でそれを達成することができます。

    私はParentView階層にViewをプログラムに基づいて追加し、レイアウト全体をリフレッシュしています。

    View inflatedDashboardView; 
        inflatedDashboardView = mInflater.inflate(R.layout.layout_drawer_dashboard, mDrawerInnerRootLayout, false); 
        mDashboardLayout = (LinearLayout) inflatedDashboardView.findViewById(R.id.activityMotherDrawerDashboardLayout); 
        mDrawerInnerRootLayout.addView(inflatedDashboardView); 
        mDrawerInnerRootLayout.forceLayout(); 
    

    まだDrawerLayoutのInnerView Layoutが常にFrameLayoutを返す理由を理解できません。

    関連する問題