2017-12-30 45 views
0

を知らないとき、私は赤いラインマッチ親項目のようなビューを作成したいのですが、私は正確に内容を知らないビューの一致親を作成します。高さ。私はあなたの問題を精巧私はこの</p> <p><a href="https://i.stack.imgur.com/pfLbA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pfLbA.png" alt="enter image description here"></a></p> <p>ようなレイアウトを持って、正確に内容の高さ

<?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

これは私のレイアウトコードで作成してみてくださいそれは

に動作していないので、ビューマージントップは、高さImageViewの幅に等しいが、私のコンテンツは、高さwrap_contentに設定されています。それは動的か静的ですか? – 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" /> 
関連する問題

 関連する問題