我想Button在Android中做到这样:
但我不知道该怎么做.我一定要使用RelativeLayout一些元素(ImageView,TextView,分离器,...)?
我真的不知道最好的做法.
您可以使用
ButtonPropertyandroid:drawableLeft="@drawable/ic_done".
请参阅此.
 <Button
        android:id="@+id/button111111"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawablePadding="5dp"
        android:layout_centerHorizontal="true"
        android:drawableLeft="@drawable/ic_done"
        android:text="Facebook" />
编辑1:
如果你想这样做而不使用
ButtonPropertyandroid:drawableLeft="@drawable/ic_done"Then.
请参阅此.
在文件夹中创建XML名为它的文件.Shape.xmlres -> drawable
如果在res目录中没有看到drawable文件夹,则创建名为drawable的文件夹.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke
        android:width="3dip"
        android:color="@android:color/black" />
    <corners android:radius="10dip" />
    <padding
        android:bottom="10dip"
        android:left="10dip"
        android:right="10dip"
        android:top="10dip" />
</shape>
然后参考这个布局.
<?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="wrap_content"
    android:background="@drawable/shape"
    android:gravity="center_vertical">
    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/app_name"
        android:src="@mipmap/ic_launcher" />
    <View
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="10dp"
        android:background="@android:color/darker_gray" />
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight="1"
        android:background="@null"
        android:text="Submit" />
</LinearLayout>
这是屏幕.
注:更改Drawable,并Color为您的选择.
| 归档时间: | 
 | 
| 查看次数: | 5832 次 | 
| 最近记录: |