Android:TextView旁边的Drawable,其重量为LinearLayout中的每个TextView

我试图实现如Pic1所示的结果.尝试设置重力,paddingleft等,但可绘制的图像出现在右端而不是文本旁边(如图2 所示).任何人都可以建议如何在TextView旁边对齐图像?另外如何设置drawable的大小?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" 
android:background="@drawable/separator"
    android:padding="10dp">

<TextView
    android:id="@+id/sms"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    android:layout_weight="1"
    android:drawableEnd="@drawable/message"
    android:drawableRight="@drawable/message"
    android:gravity="center"
    android:paddingLeft="3dp"
    android:paddingRight="3dp"
    android:text="SMS" />

<TextView
    android:id="@+id/call"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawableEnd="@drawable/call"
    android:drawableRight="@drawable/call"
    android:gravity="center"
    android:text="CALL" />

<TextView
    android:id="@+id/email"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center"
    android:drawableEnd="@drawable/mail"
    android:drawablePadding="3dp"
    android:drawableRight="@drawable/mail"
    android:text="MAIL" />

解决方法

试着围绕这个建立.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:orientation="horizontal"
    android:padding="10dp">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1">

        <TextView
            android:id="@+id/sms"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:gravity="center"
            android:drawableRight="@drawable/message"
            android:text="SMS" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1">

        <TextView
            android:id="@+id/call"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableRight="@drawable/call"

            android:gravity="center"
            android:text="CALL" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1">

        <TextView
            android:id="@+id/email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableRight="@drawable/mail"
            android:gravity="center"
            android:text="MAIL" />
    </LinearLayout>
</LinearLayout>

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...