1

私はこのような相対ビューを持っています:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/linkCardView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@layout/login_gradient_bg"
        >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_marginLeft="6dp"
        android:layout_marginRight="6dp"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="4dp"
        android:background="@drawable/card_bg">

        <TextView
            android:id="@+id/linkTitle0001"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/faviconView0001"
            android:paddingLeft="4dp"
            android:lineSpacingExtra="-2dp"
            android:fontFamily="sans-serif-condensed"
            android:maxLines="2"
            android:text="@string/link_title_001"
            android:textColor="#717171"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/linkDesc0001"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/faviconView0001"
            android:paddingBottom="4dp"
            android:fontFamily="sans-serif"
            android:maxLines="1"
            android:text="@string/link_desc_001"
            android:textColor="#acacac"
            android:textSize="13sp"   />

        <ImageView
            android:id="@+id/faviconView0001"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="6dp"
            android:paddingBottom="7dp"
            android:src="@drawable/favicon_example" />

        <ImageView
            android:id="@+id/labelSource0001"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linkDesc0001"
            android:background="@drawable/card_label" />






    </RelativeLayout>

</FrameLayout>

linkTitle0001 TextView に入力されるテキストの長さで、relativeLayout のサイズを大きくしたいと考えました。どうすればそれを達成できますか?

4

2 に答える 2

2
Try this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/linkCardView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@layout/login_gradient_bg"
        >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_marginLeft="6dp"
        android:layout_marginRight="6dp"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="4dp"
        android:background="@drawable/card_bg">

        <ImageView
            android:id="@+id/faviconView0001"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="6dp"
            android:paddingBottom="7dp"
            android:src="@drawable/favicon_example" />


        <TextView
            android:id="@+id/linkTitle0001"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/faviconView0001"
            android:paddingLeft="4dp"
            android:lineSpacingExtra="-2dp"
            android:fontFamily="sans-serif-condensed"
            android:maxLines="2"
            android:text="@string/link_title_001"
            android:textColor="#717171"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/linkDesc0001"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/faviconView0001"
            android:paddingBottom="4dp"
            android:fontFamily="sans-serif"
            android:maxLines="1"
            android:text="@string/link_desc_001"
            android:textColor="#acacac"
            android:textSize="13sp"   />


        <ImageView
            android:id="@+id/labelSource0001"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linkDesc0001"
            android:background="@drawable/card_label" />

    </RelativeLayout>

</FrameLayout>

For Textview linkTitle0001, try to put below something or align baseline with someone as per your need.
于 2013-08-16T04:41:56.263 に答える
0

それを止めるルールがないからです。source0001 は desc0001 の下にあり、desc0001 は favIcon0001 の下にあります。タイトルはファビコンの権利ですが、その下に重なってはいけないというわけではありません。基本的に、layout_below は、そのアイテムよりも右に行くのを止めません。他のすべてのアイテムを favicon と align_right にする (ファビボンの右に移動できないようにする) か、タイトルの左にレイアウトするすべてのアイテムにルールを設定する必要があります。

于 2013-08-16T04:52:31.267 に答える