Android RelativeLayout 에서 작은 문 제 를 사용 합 니 다.

3634 단어 일상 오류
Relative Layout 는 프로젝트 에서 없어 서 는 안 된다 고 할 수 있 지만 최근 에 사용 할 때 예전 에 주의 하지 않 았 던 문 제 를 발 견 했 습 니 다.저 는 Relative Layout 에서 두 개의 Relative Layout 레이아웃 을 정 의 했 지만 하 나 는 나타 나 지 않 았 습 니 다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/rl1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <Button
            android:layout_alignParentBottom="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="40sp"
            android:text="buttom"/>

    RelativeLayout>

   <RelativeLayout
       android:id="@+id/rl2"
       android:layout_below="@id/rl1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content">

       <Button
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="buttom2"
           android:textSize="50sp"
           android:layout_alignParentRight="true"/>
   RelativeLayout>

RelativeLayout>

여기 월 1 높이 는 wrap 이지 만content 하지만 rl2 는 표시 되 지 않 았 습 니 다.rl 에 button 이 안 드 로 이 드:layot 가 있 기 때 문 입 니 다.alignParent Bottom="true"속성 이기 때문에 rl1 높이 는 자가 적응 되 었 지만 가장 바깥쪽 구조의 높이 는 match 입 니 다.parent,그래서 이렇게 만 든 rl1 의 높이 는 사실 match 입 니 다.parent,이전에 이 문 제 를 주의 하지 못 했 기 때문에 여기 서 총 결 을 하 겠 습 니 다.

좋은 웹페이지 즐겨찾기