2016-07-07 10 views
0

を埋めるために力の尺度である理由は、私のテストコードです:drawerlayoutのビューは、ここで画面

<android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="ro.rotry.NdInnerViewAutoFillScreen"> 
    <TextView android:text="in drawerlayout" android:textColor="@android:color/white" android:background="@android:color/black" android:layout_width="100dp" android:layout_height="100dp"/> 
</android.support.v4.widget.DrawerLayout> 

私は次のような結果を得る:TextViewのショー100dpサイズ

作り方

enter image description here

更新

<android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" 
                android:layout_height="match_parent"> 
     <TextView android:text="in coordinator" android:textColor="@android:color/white" android:background="@android:color/black" android:layout_width="100dp" android:layout_height="100dp"/> 
    </android.support.design.widget.CoordinatorLayout> 

しかし、私はCoordinatorLayoutのない道を願って、それはあまりにも面倒だ

+2

実際に 'DrawerLayout'が必要ですか?そのレイアウトには引き出しがありません。 –

+0

@MikeM。それは私の質問を再現するだけの単純なサンプル、私は実際のコードでDrawerLayoutが必要です – asullaherc

答えて

2

DrawerLayoutの最初の子ViewがメインのコンテンツViewあり、そしてそれがレイアウトされます:私は、次のコードでそれを修正することができます設定したレイアウト属性に関係なくDrawerLayoutを入力してください。

TextViewを設定したサイズにする場合は、メインコンテンツViewとして動作する別のViewGroupにラップする必要があります。例:

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="ro.rotry.NdInnerViewAutoFillScreen"> 

    <RelativeLayout android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <TextView android:text="in drawerlayout" 
      android:textColor="@android:color/white" 
      android:background="@android:color/black" 
      android:layout_centerInParent="true" 
      android:layout_width="100dp" 
      android:layout_height="100dp"/> 

    </RelativeLayout> 

    <View android:id="@+id/drawer" 
     ... /> 

</android.support.v4.widget.DrawerLayout> 
関連する問題