如何在android中使用复合drawables?

时间:2014-02-28 23:24:09

标签: android xml

我在我的Android应用程序的xml文件中有这个代码:

    <LinearLayout
        android:orientation="horizontal"
        style="@style/Container" >

        <ImageView
            android:id="@+id/avatar"
            android:layout_width="120dp"
            android:layout_height="150dp"
            android:background="#00112d"
            android:contentDescription="@string/logoimage"
            android:src="@drawable/no_avatar" />

        <TextView
            android:id="@+id/status"
            android:background="@drawable/bg_profile_status"
            style="@style/RegularBlack"
            android:padding="10dp"
            android:autoLink="web"
            android:layout_width="0dp"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"/>

    </LinearLayout>

Android正在抱怨将其变成复合版画。有谁知道如何做到这一点?

由于

1 个答案:

答案 0 :(得分:0)

TextView mStatusTextView = (TextView) findViewById(R.id.status)
mStatusTextView.setCompoundDrawablesWithIntrinsicBounds(0,0,R.id.avatar,0);

检查一下 http://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds%28int,%20int,%20int,%20int%29