Android 学习笔记 同时展示文本与图像

java yekong 463℃

同时展示文本与图像的可能途径包括:
(1)利用LinearLayout对imageView和TextView组合布局。
(2)通过按钮控件Button的drawable***属性设置文本周围的图标。
drawableTop:指定文字上方的图片。
drawableBottom:指定文字下方的图片。
drawableleft:指定文字左边的图片。
drawableRight:指定文字右边的图片。
drawablePadding:指定图片与文字的间距。

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

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/message"
        android:drawablePadding="5dp"
        android:text="图标在左"></Button>
</LinearLayout>
喜欢 (0)