의 각 항목에 대해 android:layout_alignParentBottom
아래쪽 화살표를 사용하고 ImageView
있습니다 . 하지만 모드 에서만 완벽하게 작동하고 앱을 실행할 때 작동하지 않습니다. 왜 이런 일이 일어 났는지 모르겠습니다. 스크린 샷에서 내 문제에 대해 자세히 설명했습니다.RelativeLayout
RecyleView
Preview
<android.support.v7.widget.CardView
android:id="@+id/cv"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/item_layoutStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#E8F5E9"
android:orientation="vertical">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/item_tvRepeatTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="10" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0"
android:layout_alignTop="@id/item_layoutStart"
android:layout_alignBottom="@id/item_layoutStart"
android:orientation="vertical"
android:layout_toRightOf="@id/item_layoutStart">
<TextView
android:id="@+id/item_tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="aa aa aaaaaa aa aa aaaaaa aa aa aaaaaa " />
<TextView
android:id="@+id/item_tvResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/item_tvTitle"
android:text="aa aa aaaaaa aa aa aaaaaa aa aa aaaaaa" />
<ImageView android:id="@+id/item_ivExpand"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:padding="3dp"
android:src="@drawable/selector_arrow_down"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
업데이트RelativeLayout
특정 값 으로 내 키를 고정 하면 android:layout_alignParentBottom
작업
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
>
하지만 제 경우에는 RelativeLayout
높이가LinearLayout
<RelativeLayout
android:layout_alignTop="@id/item_layoutStart"
android:layout_alignBottom="@id/item_layoutStart"
>
android:layout_alignParentBottom
작동하지
어떤 도움이라도 대단히 감사하겠습니다.
Though this solution apparently messes with the way the layout looks in the editor, it solves the problem of the runtime layout.
First, change the outer RelativeLayout
to a LinearLayout
. Then, on the inner RelativeLayout
, remove the layout_alignTop
and layout_alignBottom
attributes altogether, and set the layout_height
to match_parent
.
As you can see in the posted screenshots, that ImageView
was being laid out as though its parent RelativeLayout
's height was wrapping its child View
s, as per its layout_height
setting. However, after the RelativeLayout
's child View
s were laid out, its layout_alignTop
and layout_alignBottom
attributes were being applied, and it was resized to match the LinearLayout
's height, but that ImageView
just stayed where it was.
를 사용하여 LinearLayout
외부에 대한 ViewGroup
, 그리고 내부 설정 RelativeLayout
'으로의 높이 match_parent
의이 RelativeLayout
그것을 밖으로 자식 배치하기 전에 일정한 높이를 적용했다 View
들과 ImageView
의 layout_alignParentRight
와 layout_alignParentBottom
속성은 정확한 지점에 착륙했다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다