2017-12-30 18 views
0

내가 가진이보기 일치하는 부모를 만들기 정확히 내용 높이

enter image description here

내가 빨간색 선 일치 상위 항목과 같은 뷰를 만들려면,하지만 난 정확히 컨텐츠 모르는 같은 레이아웃 신장. 내가보기 마진 최고 높이의 이미지 뷰의 폭과 동일 만들려고하지만, 내 콘텐츠는 높이 wrap_content을 설정, 그래서 그것은

작동하지 않을 것이 내 레이아웃 코드

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<ImageView 
    android:id="@+id/img" 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:src="@drawable/common_google_signin_btn_icon_dark" /> 

<TextView 
    android:id="@+id/txtContent" 
    android:layout_width="50dp" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="50dp" 
    android:layout_toRightOf="@id/img" /> 

<View 
    android:id="@+id/line" 
    android:layout_width="5dp" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="25dp" 
    android:layout_marginTop="50dp" 
    android:background="@color/colorAccent" /> 

+0

문제를 정교 . 동적 또는 정적입니까 ?? – JUL2791

+0

그것은 역설적이다, 나의 내용은 바뀔 수있다. – truongsen

답변

0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<ImageView 
android:id="@+id/img" 
android:layout_width="50dp" 
android:layout_height="50dp" 
android:src="@drawable/common_google_signin_btn_icon_dark" /> 

<TextView 
android:id="@+id/txtContent" 
android:layout_width="50dp" 
android:layout_height="wrap_content" 
android:layout_marginTop="50dp" 
android:layout_toRightOf="@id/img" /> 

<View 
android:id="@+id/line" 
android:layout_width="50dp" 
android:layout_height="5dp" 
android:layout_below="@+id/txtContent" 
android:background="@color/colorAccent" />